@@ -11,14 +11,15 @@ AdvancedMH works by accepting some log density function which is used to constru
11
11
``` julia
12
12
# Import the package.
13
13
using AdvancedMH
14
+ using Distributions
15
+
16
+ # Generate a set of data from the posterior we want to estimate.
17
+ data = rand (Normal (0 , 1 ), 30 )
14
18
15
19
# Define the components of a basic model.
16
20
insupport (θ) = θ[2 ] >= 0
17
21
dist (θ) = Normal (θ[1 ], θ[2 ])
18
- density (data, θ) = insupport (θ) ? sum (logpdf .(dist (θ), data)) : - Inf
19
-
20
- # Generate a set of data from the posterior we want to estimate.
21
- data = rand (Normal (0 , 1 ), 30 )
22
+ density (θ) = insupport (θ) ? sum (logpdf .(dist (θ), data)) : - Inf
22
23
23
24
# Construct a DensityModel.
24
25
model = DensityModel (density)
@@ -46,19 +47,19 @@ parameters = μ, σ
46
47
47
48
Summary Statistics
48
49
49
- │ Row │ parameters │ mean │ std │ naive_se │ mcse │ ess │ r_hat │
50
- │ │ Symbol │ Float64 │ Float64 │ Float64 │ Float64 │ Any │ Any │
51
- ├─────┼────────────┼──────────┼──────────┼─ ────────────┼────────────┼─────────┼─────────┤
52
- │ 1 │ μ │ - 0.23908 │ 0.187608 │ 0.00059327 │ 0.00310081 │ 3225.02 │ 1.00003 │
53
- │ 2 │ σ │ 0.98903 │ 0.138437 │ 0.000437777 │ 0.00242748 │ 2830.8 │ 1.0003 │
50
+ │ Row │ parameters │ mean │ std │ naive_se │ mcse │ ess │ r_hat │
51
+ │ │ Symbol │ Float64 │ Float64 │ Float64 │ Float64 │ Any │ Any │
52
+ ├─────┼────────────┼─────────── ┼──────────┼────────────┼────────────┼─────────┼─────────┤
53
+ │ 1 │ μ │ 0.0834188 │ 0.241418 │ 0.00076343 │ 0.00341067 │ 4693.04 │ 1.00008 │
54
+ │ 2 │ σ │ 1.33116 │ 0.184111 │ 0.00058221 │ 0.00258778 │ 4965.83 │ 1.00001 │
54
55
55
56
Quantiles
56
57
57
- │ Row │ parameters │ 2.5 % │ 25.0 % │ 50.0 % │ 75.0 % │ 97.5 % │
58
- │ │ Symbol │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │
59
- ├─────┼────────────┼──────────┼───────────┼───────────┼─ ──────────┼──────────┤
60
- │ 1 │ μ │ - 0.61185 │ - 0.360519 │ - 0.236016 │ - 0.119666 │ 0.134902 │
61
- │ 2 │ σ │ 0.758477 │ 0.887894 │ 0.973777 │ 1.07983 │ 1.29455 │
58
+ │ Row │ parameters │ 2.5 % │ 25.0 % │ 50.0 % │ 75.0 % │ 97.5 % │
59
+ │ │ Symbol │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │
60
+ ├─────┼────────────┼─────────── ┼──────────── ┼───────────┼──────────┼──────────┤
61
+ │ 1 │ μ │ - 0.393769 │ - 0.0771134 │ 0.0801688 │ 0.241162 │ 0.564331 │
62
+ │ 2 │ σ │ 1.03685 │ 1.2044 │ 1.30992 │ 1.43609 │ 1.75745 │
62
63
```
63
64
64
65
## Custom proposals
0 commit comments