Skip to content

Commit f58c636

Browse files
authored
Merge branch 'master' into torfjelde/logdensitymodel
2 parents 8ad165a + 9b3ac5a commit f58c636

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

.github/workflows/CompatHelper.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,32 @@ name: CompatHelper
22

33
on:
44
schedule:
5-
- cron: '00 00 * * *'
5+
- cron: 0 0 * * *
6+
workflow_dispatch:
67

78
jobs:
89
CompatHelper:
910
runs-on: ubuntu-latest
1011
steps:
11-
- uses: julia-actions/setup-julia@latest
12-
with:
13-
version: 1.3
14-
- name: Pkg.add("CompatHelper")
15-
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
16-
- name: CompatHelper.main()
12+
- name: "Add the General registry via Git"
13+
run: |
14+
import Pkg
15+
ENV["JULIA_PKG_SERVER"] = ""
16+
Pkg.Registry.add("General")
17+
shell: julia --color=yes {0}
18+
- name: "Install CompatHelper"
19+
run: |
20+
import Pkg
21+
name = "CompatHelper"
22+
uuid = "aa819f21-2bde-4658-8897-bab36330d9b7"
23+
version = "3"
24+
Pkg.add(; name, uuid, version)
25+
shell: julia --color=yes {0}
26+
- name: "Run CompatHelper"
27+
run: |
28+
import CompatHelper
29+
CompatHelper.main(; subdirs = ["", "test"], bump_version=true)
30+
shell: julia --color=yes {0}
1731
env:
1832
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19-
run: julia -e 'using CompatHelper; CompatHelper.main()'
33+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,19 @@ rw_prop = RandomWalkProposal(Normal(0,1))
129129
Different methods are easily composeable. One parameter can be static and another can be a random walk,
130130
each of which may be drawn from separate distributions.
131131

132-
## Multithreaded sampling
132+
## Multiple chains
133133

134-
AdvancedMH.jl implements the interface of [AbstractMCMC](https://github.com/TuringLang/AbstractMCMC.jl/), which means you get multiple chain sampling
135-
in parallel for free:
134+
AdvancedMH.jl implements the interface of [AbstractMCMC](https://github.com/TuringLang/AbstractMCMC.jl/) which means sampling of multiple chains is supported for free:
136135

137136
```julia
138-
# Sample 4 chains from the posterior.
139-
chain = psample(model, RWMH(init_params), 100000, 4; param_names=["μ","σ"], chain_type=Chains)
137+
# Sample 4 chains from the posterior serially, without thread or process parallelism.
138+
chain = sample(model, RWMH(init_params), MCMCSerial(), 100000, 4; param_names=["μ","σ"], chain_type=Chains)
139+
140+
# Sample 4 chains from the posterior using multiple threads.
141+
chain = sample(model, RWMH(init_params), MCMCThreads(), 100000, 4; param_names=["μ","σ"], chain_type=Chains)
142+
143+
# Sample 4 chains from the posterior using multiple processes.
144+
chain = sample(model, RWMH(init_params), MCMCDistributed(), 100000, 4; param_names=["μ","σ"], chain_type=Chains)
140145
```
141146

142147
## Metropolis-adjusted Langevin algorithm (MALA)

src/AdvancedMH.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export
2424
MALA
2525

2626
# Reexports
27-
export sample, MCMCThreads, MCMCDistributed
27+
export sample, MCMCThreads, MCMCDistributed, MCMCSerial
2828

2929
# Abstract type for MH-style samplers. Needs better name?
3030
abstract type MHSampler <: AbstractMCMC.AbstractSampler end
@@ -35,26 +35,26 @@ abstract type AbstractTransition end
3535
# Define a model type. Stores the log density function and the data to
3636
# evaluate the log density on.
3737
"""
38-
DensityModel{F<:Function} <: AbstractModel
38+
DensityModel{F} <: AbstractModel
3939
4040
`DensityModel` wraps around a self-contained log-liklihood function `logdensity`.
4141
4242
Example:
4343
4444
```julia
45-
l
46-
DensityModel
45+
l(x) = logpdf(Normal(), x)
46+
DensityModel(l)
4747
```
4848
"""
49-
struct DensityModel{F<:Function} <: AbstractMCMC.AbstractModel
49+
struct DensityModel{F} <: AbstractMCMC.AbstractModel
5050
logdensity :: F
5151
end
5252

5353
const DensityModelOrLogDensityModel = Union{<:DensityModel,<:AbstractMCMC.LogDensityModel}
5454

5555
# Create a very basic Transition type, only stores the
5656
# parameter draws and the log probability of the draw.
57-
struct Transition{T<:Union{Vector, Real, NamedTuple}, L<:Real} <: AbstractTransition
57+
struct Transition{T,L<:Real} <: AbstractTransition
5858
params :: T
5959
lp :: L
6060
end

0 commit comments

Comments
 (0)