1
1
using AdvancedMH
2
+ using DiffResults
2
3
using Distributions
3
- using StructArrays
4
+ using ForwardDiff
4
5
using MCMCChains
6
+ using StructArrays
5
7
8
+ using LinearAlgebra
6
9
using Random
7
10
using Test
8
- using DiffResults
9
- using ForwardDiff
10
11
11
12
include (" util.jl" )
12
13
@@ -28,7 +29,7 @@ include("util.jl")
28
29
@testset " StaticMH" begin
29
30
# Set up our sampler with initial parameters.
30
31
spl1 = StaticMH ([Normal (0 ,1 ), Normal (0 , 1 )])
31
- spl2 = StaticMH (MvNormal ([ 0.0 , 0.0 ], 1 ))
32
+ spl2 = StaticMH (MvNormal (zeros ( 2 ), I ))
32
33
33
34
# Sample from the posterior.
34
35
chain1 = sample (model, spl1, 100000 ; chain_type= StructArray, param_names= [" μ" , " σ" ])
@@ -44,7 +45,7 @@ include("util.jl")
44
45
@testset " RandomWalk" begin
45
46
# Set up our sampler with initial parameters.
46
47
spl1 = RWMH ([Normal (0 ,1 ), Normal (0 , 1 )])
47
- spl2 = RWMH (MvNormal ([ 0.0 , 0.0 ], 1 ))
48
+ spl2 = RWMH (MvNormal (zeros ( 2 ), I ))
48
49
49
50
# Sample from the posterior.
50
51
chain1 = sample (model, spl1, 100000 ; chain_type= StructArray, param_names= [" μ" , " σ" ])
@@ -245,8 +246,8 @@ include("util.jl")
245
246
246
247
@testset " MALA" begin
247
248
# Set up the sampler.
248
- sigma = 1e-1
249
- spl1 = MALA (x -> MvNormal ((sigma ^ 2 / 2 ) .* x, sigma ))
249
+ σ² = 0.01
250
+ spl1 = MALA (x -> MvNormal ((σ² / 2 ) .* x, σ² * I ))
250
251
251
252
# Sample from the posterior with initial parameters.
252
253
chain1 = sample (model, spl1, 100000 ; init_params= ones (2 ), chain_type= StructArray, param_names= [" μ" , " σ" ])
0 commit comments