Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ uuid = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
keywords = ["markov chain monte carlo", "probabilistic programming"]
license = "MIT"
desc = "A lightweight interface for common MCMC methods."
version = "5.13.0"
version = "5.14.0"

[deps]
BangBang = "198e06fe-97b7-11e9-32a5-e1d131e6ad66"
Expand Down
51 changes: 29 additions & 22 deletions src/AbstractMCMC.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ parameter samples generated through a MCMC process.
"""
abstract type AbstractChains end

"""
AbstractSampler

The `AbstractSampler` type is intended to be inherited from when
implementing a custom sampler. Any persistent state information should be
saved in a subtype of `AbstractSampler`.

When defining a new sampler, you should also overload the function
`transition_type`, which tells the `sample` function what type of parameter
it should expect to receive.
"""
abstract type AbstractSampler end

"""
AbstractModel

An `AbstractModel` represents a generic model type that can be used to perform inference.
"""
abstract type AbstractModel end

"""
AbstractMCMC.from_samples(::Type{T}, samples::Matrix) where {T<:AbstractChains}

Expand All @@ -53,36 +73,23 @@ samples))` where `samples::Matrix{Tsample}`.
function from_samples end

"""
AbstractMCMC.to_samples(::Type{T}, chains::AbstractChains) where {T}
AbstractMCMC.to_samples(::Type{T}, chains::AbstractChains[, model::AbstractModel]) where {T}

Convert an `AbstractChains` object to an `Matrix` of parameter samples.

Methods of this function should be implemented with the signature listed above, and should
return a `Matrix{T}`.

See also: [`from_samples`](@ref).
"""
function to_samples end

"""
AbstractSampler
The `model` argument is optional: implementations that require model information to extract
the parameter samples may accept it. If you do not need the model information, you can
implement only the method without the `model` argument, and the three-argument version will
default to calling the two-argument version.

The `AbstractSampler` type is intended to be inherited from when
implementing a custom sampler. Any persistent state information should be
saved in a subtype of `AbstractSampler`.

When defining a new sampler, you should also overload the function
`transition_type`, which tells the `sample` function what type of parameter
it should expect to receive.
"""
abstract type AbstractSampler end

"""
AbstractModel

An `AbstractModel` represents a generic model type that can be used to perform inference.
See also: [`from_samples`](@ref).
"""
abstract type AbstractModel end
function to_samples(::Type{T}, chains::AbstractChains, model::AbstractModel) where {T}
return to_samples(T, chains)
end

"""
AbstractMCMCEnsemble
Expand Down
Loading