diff --git a/previews/PR103/.documenter-siteinfo.json b/previews/PR103/.documenter-siteinfo.json index 1ae3345..cca91de 100644 --- a/previews/PR103/.documenter-siteinfo.json +++ b/previews/PR103/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-10-22T18:50:10","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.1","generation_timestamp":"2024-10-22T18:51:35","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/previews/PR103/api/index.html b/previews/PR103/api/index.html index cf96b11..c0d461c 100644 --- a/previews/PR103/api/index.html +++ b/previews/PR103/api/index.html @@ -2,5 +2,5 @@ AdvancedMH.jl · AdvancedMH

AdvancedMH.jl

Documentation for AdvancedMH.jl

Structs

AdvancedMH.MetropolisHastingsType
MetropolisHastings{D}

MetropolisHastings has one field, proposal. proposal is a Proposal, NamedTuple of Proposal, or Array{Proposal} in the shape of your data. For example, if you wanted the sampler to return a NamedTuple with shape

x = (a = 1.0, b=3.8)

The proposal would be

proposal = (a=StaticProposal(Normal(0,1)), b=StaticProposal(Normal(0,1)))

Other allowed proposals are

p1 = StaticProposal(Normal(0,1))
 p2 = StaticProposal([Normal(0,1), InverseGamma(2,3)])
 p3 = StaticProposal((a=Normal(0,1), b=InverseGamma(2,3)))
-p4 = StaticProposal((x=1.0) -> Normal(x, 1))

The sampler is constructed using

spl = MetropolisHastings(proposal)

When using MetropolisHastings with the function sample, the following keyword arguments are allowed:

  • initial_params defines the initial parameterization for your model. If

none is given, the initial parameters will be drawn from the sampler's proposals.

  • param_names is a vector of strings to be assigned to parameters. This is only

used if chain_type=Chains.

  • chain_type is the type of chain you would like returned to you. Supported

types are chain_type=Chains if MCMCChains is imported, or chain_type=StructArray if StructArrays is imported.

source

Functions

AdvancedMH.DensityModelType
DensityModel{F} <: AbstractModel

DensityModel wraps around a self-contained log-liklihood function logdensity.

Example:

l(x) = logpdf(Normal(), x)
-DensityModel(l)
source
+p4 = StaticProposal((x=1.0) -> Normal(x, 1))

The sampler is constructed using

spl = MetropolisHastings(proposal)

When using MetropolisHastings with the function sample, the following keyword arguments are allowed:

none is given, the initial parameters will be drawn from the sampler's proposals.

used if chain_type=Chains.

types are chain_type=Chains if MCMCChains is imported, or chain_type=StructArray if StructArrays is imported.

source

Functions

AdvancedMH.DensityModelType
DensityModel{F} <: AbstractModel

DensityModel wraps around a self-contained log-liklihood function logdensity.

Example:

l(x) = logpdf(Normal(), x)
+DensityModel(l)
source
diff --git a/previews/PR103/index.html b/previews/PR103/index.html index 77d37d3..25a3303 100644 --- a/previews/PR103/index.html +++ b/previews/PR103/index.html @@ -109,4 +109,4 @@ # Sample from the posterior. chain = sample(model, spl, 100000; initial_params=ones(2), chain_type=StructArray, param_names=["μ", "σ"])

Usage with LogDensityProblems.jl

As above, we can define the model with the LogDensityProblems.jl interface. We can implement the gradient of the log density function manually, or use LogDensityProblemsAD.jl to provide us with the gradient computation used in MALA. Using our implementation of the LogDensityProblems.jl interface above:

using LogDensityProblemsAD
 model_with_ad = LogDensityProblemsAD.ADgradient(Val(:ForwardDiff), LogTargetDensity())
-sample(model_with_ad, spl, 100000; initial_params=ones(2), chain_type=StructArray, param_names=["μ", "σ"])
+sample(model_with_ad, spl, 100000; initial_params=ones(2), chain_type=StructArray, param_names=["μ", "σ"])