Skip to content

Commit 30f89e5

Browse files
committed
Update README
1 parent 2e47510 commit 30f89e5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ AdvancedMH.jl currently provides a robust implementation of random walk Metropol
44

55
Further development aims to provide a suite of adaptive Metropolis-Hastings implementations.
66

7+
Currently there are two sampler types. The first is `RWMH`, which represents random-walk MH sampling, and the second is `StaticMH`, which draws proposals
8+
from only a prior distribution without incrementing the previous sample.
9+
710
## Usage
811

912
AdvancedMH works by accepting some log density function which is used to construct a `DensityModel`. The `DensityModel` is then used in a `sample` call.
@@ -25,7 +28,7 @@ density(θ) = insupport(θ) ? sum(logpdf.(dist(θ), data)) : -Inf
2528
model = DensityModel(density)
2629

2730
# Set up our sampler with initial parameters.
28-
spl = MetropolisHastings([0.0, 0.0])
31+
spl = RWMH([0.0, 0.0])
2932

3033
# Sample from the posterior.
3134
chain = sample(model, spl, 100000; param_names=["μ", "σ"])
@@ -68,5 +71,16 @@ Custom proposal distributions can be specified by passing a distribution to `Met
6871

6972
```julia
7073
# Set up our sampler with initial parameters.
71-
spl = MetropolisHastings([0.0, 0.0], MvNormal(2, 0.5))
74+
spl1 = RWMH([0.0, 0.0], MvNormal(2, 0.5))
75+
spl2 = StaticMH([0.0, 0.0], MvNormal(2, 0.5))
76+
```
77+
78+
## Multithreaded sampling
79+
80+
AdvancedMH.jl implements the interface of [AbstractMCMC](https://github.com/TuringLang/AbstractMCMC.jl/), which means you get multiple chain sampling
81+
in parallel for free:
82+
83+
```julia
84+
# Sample 4 chains from the posterior.
85+
chain = psample(model, RWMH(init_params), 100000, 4; param_names=["μ","σ"])
7286
```

0 commit comments

Comments
 (0)