Skip to content

Commit 11f3b64

Browse files
Tor FjeldeTor Fjelde
authored andcommitted
made the docstring for RAM a bit nicer
1 parent 4764120 commit 11f3b64

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/RobustAdaptiveMetropolis.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ $(FIELDS)
1414
1515
The following demonstrates how to implement a simple Gaussian model and sample from it using the RAM algorithm.
1616
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
1919
2020
julia> # Define a Gaussian with zero mean and some covariance.
2121
struct Gaussian{A}
@@ -43,11 +43,13 @@ julia> # Number of warmup steps, i.e. the number of steps to adapt the covarianc
4343
# by default in the `sample` call. To include them, pass `discard_initial=0` to `sample`.
4444
num_warmup = 10_000;
4545
46-
julia> # Set the seed so get some consistency.
47-
Random.seed!(1234);
48-
4946
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+
);
5153
5254
julia> isapprox(cov(Array(chain)), model.A; rtol = 0.2)
5355
true
@@ -59,7 +61,7 @@ It's also possible to restrict the eigenvalues to avoid either too small or too
5961
julia> chain = sample(
6062
model,
6163
RobustAdaptiveMetropolis(eigenvalue_lower_bound=0.1, eigenvalue_upper_bound=2.0),
62-
10_000;
64+
num_samples;
6365
chain_type=Chains, num_warmup, progress=false, initial_params=zeros(2)
6466
);
6567

0 commit comments

Comments
 (0)