diff --git a/Project.toml b/Project.toml index 775a50c..78d2aca 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "AdvancedMH" uuid = "5b7e9947-ddc0-4b3f-9b55-0d8042f74170" -version = "0.6.5" +version = "0.6.6" [deps] AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001" diff --git a/README.md b/README.md index 6f05a18..1dece12 100644 --- a/README.md +++ b/README.md @@ -111,14 +111,19 @@ rw_prop = RandomWalkProposal(Normal(0,1)) Different methods are easily composeable. One parameter can be static and another can be a random walk, each of which may be drawn from separate distributions. -## Multithreaded sampling +## Multiple chains -AdvancedMH.jl implements the interface of [AbstractMCMC](https://github.com/TuringLang/AbstractMCMC.jl/), which means you get multiple chain sampling -in parallel for free: +AdvancedMH.jl implements the interface of [AbstractMCMC](https://github.com/TuringLang/AbstractMCMC.jl/) which means sampling of multiple chains is supported for free: ```julia -# Sample 4 chains from the posterior. -chain = psample(model, RWMH(init_params), 100000, 4; param_names=["μ","σ"], chain_type=Chains) +# Sample 4 chains from the posterior serially, without thread or process parallelism. +chain = sample(model, RWMH(init_params), MCMCSerial(), 100000, 4; param_names=["μ","σ"], chain_type=Chains) + +# Sample 4 chains from the posterior using multiple threads. +chain = sample(model, RWMH(init_params), MCMCThreads(), 100000, 4; param_names=["μ","σ"], chain_type=Chains) + +# Sample 4 chains from the posterior using multiple processes. +chain = sample(model, RWMH(init_params), MCMCDistributed(), 100000, 4; param_names=["μ","σ"], chain_type=Chains) ``` ## Metropolis-adjusted Langevin algorithm (MALA) diff --git a/src/AdvancedMH.jl b/src/AdvancedMH.jl index dadc411..613472b 100644 --- a/src/AdvancedMH.jl +++ b/src/AdvancedMH.jl @@ -22,7 +22,7 @@ export MALA # Reexports -export sample, MCMCThreads, MCMCDistributed +export sample, MCMCThreads, MCMCDistributed, MCMCSerial # Abstract type for MH-style samplers. Needs better name? abstract type MHSampler <: AbstractMCMC.AbstractSampler end