Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
torfjelde committed Sep 25, 2024
1 parent 1e0384d commit dcf589b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ makedocs(
sitename = "MCMCTempering",
format = Documenter.HTML(),
modules = [MCMCTempering],
pages=["Home" => "index.md", "getting-started.md", "api.md"],
pages = ["Home" => "index.md", "getting-started.md", "api.md"],
warnonly = true
)

# Deply!
Expand Down
11 changes: 11 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ MCMCTempering.swap_step

## Other samplers

To make a sampler work with MCMCTempering.jl, the sampler needs to implement a few methods:

```@docs
MCMCTempering.getparams
MCMCTempering.getlogprob
MCMCTempering.getparams_and_logprob
MCMCTempering.setparams_and_logprob!!
```

Other useful methods are:

```@docs
MCMCTempering.saveall
```
Expand Down
16 changes: 8 additions & 8 deletions docs/src/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ Let's instead try to use a _tempered_ version of `RWMH`. _But_ before we do that

To do that we need to implement two methods. First we need to tell MCMCTempering how to extract the parameters, and potentially the log-probabilities, from a `AdvancedMH.Transition`:

```@docs
```@docs; canonical=false
MCMCTempering.getparams_and_logprob
```

And similarly, we need a way to _update_ the parameters and the log-probabilities of a `AdvancedMH.Transition`:

```@docs
```@docs; canonical=false
MCMCTempering.setparams_and_logprob!!
```

Expand Down Expand Up @@ -159,10 +159,7 @@ using AdvancedHMC: AdvancedHMC
using ForwardDiff: ForwardDiff # for automatic differentation of the logdensity
# Creation of the sampler.
metric = AdvancedHMC.DiagEuclideanMetric(1)
integrator = AdvancedHMC.Leapfrog(0.1)
proposal = AdvancedHMC.StaticTrajectory(integrator, 8)
sampler = AdvancedHMC.HMCSampler(proposal, metric)
sampler = AdvancedHMC.HMC(0.1, 8)
sampler_tempered = MCMCTempering.TemperedSampler(sampler, inverse_temperatures)
# Sample!
Expand All @@ -172,6 +169,7 @@ chain = sample(
target_model, sampler, num_iterations;
chain_type=MCMCChains.Chains,
param_names=["x"],
n_adapts=0, # HACK: need this to make AdvancedHMC.jl happy :/
)
plot(chain, size=figsize)
```
Expand Down Expand Up @@ -205,7 +203,8 @@ chain_tempered_all = sample(
StableRNG(42),
target_model, sampler_tempered, num_iterations;
chain_type=Vector{MCMCChains.Chains},
param_names=["x"]
param_names=["x"],
n_adapts=0, # HACK: need this to make AdvancedHMC.jl happy :/
);
```

Expand Down Expand Up @@ -289,7 +288,8 @@ chain_tempered_all = sample(
StableRNG(42),
target_model, sampler_tempered, num_iterations;
chain_type=Vector{MCMCChains.Chains},
param_names=["x"]
param_names=["x"],
n_adapts=0, # HACK: need this to make AdvancedHMC.jl happy :/
);
```

Expand Down

0 comments on commit dcf589b

Please sign in to comment.