@@ -14,8 +14,8 @@ $(FIELDS)
14
14
15
15
The following demonstrates how to implement a simple Gaussian model and sample from it using the RAM algorithm.
16
16
17
- ```jldoctest ram-gaussian
18
- julia> using AdvancedMH, Random, Distributions, MCMCChains, LogDensityProblems, LinearAlgebra
17
+ ```jldoctest ram-gaussian; setup=:(using Random; Random.seed!(1234);)
18
+ julia> using AdvancedMH, Distributions, MCMCChains, LogDensityProblems, LinearAlgebra
19
19
20
20
julia> # Define a Gaussian with zero mean and some covariance.
21
21
struct Gaussian{A}
@@ -43,11 +43,13 @@ julia> # Number of warmup steps, i.e. the number of steps to adapt the covarianc
43
43
# by default in the `sample` call. To include them, pass `discard_initial=0` to `sample`.
44
44
num_warmup = 10_000;
45
45
46
- julia> # Set the seed so get some consistency.
47
- Random.seed!(1234);
48
-
49
46
julia> # Sample!
50
- chain = sample(model, RobustAdaptiveMetropolis(), 10_000; chain_type=Chains, num_warmup, progress=false, initial_params=zeros(2));
47
+ chain = sample(
48
+ model,
49
+ RobustAdaptiveMetropolis(),
50
+ num_samples;
51
+ chain_type=Chains, num_warmup, progress=false, initial_params=zeros(2)
52
+ );
51
53
52
54
julia> isapprox(cov(Array(chain)), model.A; rtol = 0.2)
53
55
true
@@ -59,7 +61,7 @@ It's also possible to restrict the eigenvalues to avoid either too small or too
59
61
julia> chain = sample(
60
62
model,
61
63
RobustAdaptiveMetropolis(eigenvalue_lower_bound=0.1, eigenvalue_upper_bound=2.0),
62
- 10_000 ;
64
+ num_samples ;
63
65
chain_type=Chains, num_warmup, progress=false, initial_params=zeros(2)
64
66
);
65
67
0 commit comments