|
185 | 185 | mcmc_params = |
186 | 186 | Dict(:mcmc_alg => RWMHSampling(), :obs_sample => obs_sample, :init_params => [3.0], :step => 0.5, :rng => rng) |
187 | 187 |
|
| 188 | + |
188 | 189 | @testset "Constructor: standardize" begin |
189 | 190 | em = test_gp_1(y, σ2_y, iopairs) |
190 | 191 | test_obs = MarkovChainMonteCarlo.to_decorrelated(obs_sample, em) |
@@ -281,40 +282,37 @@ end |
281 | 282 |
|
282 | 283 | end |
283 | 284 |
|
284 | | - @testset "Sine GP & ForwardDiff-based variants" begin |
285 | 285 |
|
286 | 286 |
|
287 | | - mcmc_params = |
288 | | - Dict(:obs_sample => obs_sample, :init_params => [3.0], :step => 0.1, :rng => rng, :target_acc => 0.6) # the target is usually higher in grad-based MCMC |
289 | 287 |
|
290 | | - em_1, em_1b = test_gp_and_agp_1(y, σ2_y, iopairs) |
291 | | - # em_1 cannot be used here |
292 | | - |
293 | | - mcmc_algs = [ |
294 | | - BarkerSampling(), # robust |
295 | | - # MALASampling(), # very sensitive to :step in mcmc |
296 | | - # infMALASampling(), # very sensitive to :step |
297 | | - InfmMALASampling(), # more robust but incorrect posterior mean |
298 | | - BarkerSampling(), # robust |
299 | | - # HMCSampling(), # NaNs? |
300 | | - # infHMCSampling(), # NaNs? |
301 | | - InfmHMCSampling(), # NaNs? |
302 | | - ] |
303 | | - |
304 | | - # GPJL doesnt support ForwardDiff |
305 | | - @test_throws ErrorException new_step, posterior_mean, chain = |
306 | | - mcmc_test_template(prior, σ2_y, em_1; mcmc_alg = mcmc_algs[1], mcmc_params...) |
307 | | - |
308 | | - for alg in mcmc_algs |
309 | | - @info "testing algorithm: $(alg)" |
310 | | - new_step, posterior_mean, chain = mcmc_test_template(prior, σ2_y, em_1b; mcmc_alg = alg, mcmc_params...) |
311 | | - esjd_tmp = esjd(chain) |
312 | | - @info "ESJD = $esjd_tmp" |
313 | | - @info posterior_mean |
314 | | - @test isapprox(posterior_mean, π / 2; atol = 4e-1) |
| 288 | + mcmc_params = Dict(:obs_sample => obs_sample, :init_params => [3.0], :step => 0.01, :rng => rng, :target_acc => 0.6) # the target is usually higher in grad-based MCMC |
315 | 289 |
|
316 | | - end |
| 290 | + em_1, em_1b = test_gp_and_agp_1(y, σ2_y, iopairs) |
| 291 | + # em_1 cannot be used here |
317 | 292 |
|
| 293 | + mcmc_algs = [ |
| 294 | + BarkerSampling(), # |
| 295 | + MALASampling(), # |
| 296 | + InfMALASampling(), # |
| 297 | + InfmMALASampling(), # |
| 298 | + HMCSampling(), # |
| 299 | + InfHMCSampling(), # |
| 300 | + InfmHMCSampling(), # |
| 301 | + ] |
| 302 | + |
| 303 | + # GPJL doesnt support ForwardDiff |
| 304 | + @test_throws ErrorException new_step, posterior_mean, chain = |
| 305 | + mcmc_test_template(prior, σ2_y, em_1; mcmc_alg = mcmc_algs[1], mcmc_params...) |
| 306 | + |
| 307 | + for alg in mcmc_algs |
| 308 | + @info "testing algorithm: $(nameof(typeof(alg)))" |
| 309 | + new_step, posterior_mean, chain = mcmc_test_template(prior, σ2_y, em_1b; mcmc_alg = alg, mcmc_params...) |
| 310 | + esjd_tmp = esjd(chain) |
| 311 | + @info "ESJD = $esjd_tmp" |
| 312 | + @info posterior_mean |
| 313 | + @testset "Sine GP & ForwardDiff variant:$(nameof(typeof(alg)))" begin |
| 314 | + @test isapprox(posterior_mean, π / 2; atol = 4e-1) |
| 315 | + end |
318 | 316 |
|
319 | 317 | end |
320 | 318 |
|
|
0 commit comments