Releases: TuringLang/MCMCChains.jl
Releases · TuringLang/MCMCChains.jl
v0.3.11
v0.3.10
v0.3.9
v0.3.8
DataFrames, hpd export.
- Fixes a quantile issue
- Exports the
hpd
function - Uses
DataFrames
for all statistics functions
Quantiles Hotfix
Sampling, Arrays, and DataFrames
- You can now use the sampling API from
StatsBase
to pull random samples from your chain (#68) - Supports
Array(chn)
to create a simpleArray
object from aChains
object (#73) - Export your chain to a
DataFrame
(#73)
The README file contains more information on how to use the above features, but here's the relevant section:
Exporting Chains
A few utility export functions have been provided to convert Chains
objects to either an Array or a DataFrame:
# Several examples of creating an Array object:
Array(chns)
Array(chns[:s])
Array(chns, [:parameters])
Array(chns, [:parameters, :internals])
# By default chains are appended. This can be disabled
# using the append_chains keyword argument:
Array(chns, append_chains=false)
# This will return an `Array{Array, 1}` object containing
# an Array for each chain.
# A final option is:
Array(chns, remove_missing_union=false)
# This will not convert the Array columns from a
`Union{Missing, Real}` to a `Vector{Real}`.
Similarly, for DataFrames:
DataFrame(chns)
DataFrame(chns[:s])
DataFrame(chns, [:parameters])
DataFrame(chns, [:parameters, :internals])
DataFrame(chns, append_chains=false)
DataFrame(chns, remove_missing_union=false)
See also ?MCMCChains.DataFrame and ?MCMCChains.Array for more help.
Sampling Chains
MCMCChains overloads several sample()
methods as defined in StatsBase:
# Sampling `n` samples from the chain `a`. Optionally
# weighting the samples using `wv`.
sample([rng], a, [wv::AbstractWeights], n::Integer)
# E.g. creating 10000 weighted samples:
c = kde(Array(chn[:s]))
chn_weighted_sample = sample(c.x, Weights(c.density), 100000)
# As above, but supports replacing and ordering.
sample([rng], a, [wv::AbstractWeights], n::Integer; replace=true,
ordered=false)
See also ?MCMCChains.sample for additional help.
Hotfix
Index changes and bug fixes
- Diagnostic functions now support
section = :section_name
as keyword arguments (#54) - Corner plots have been fixed to work with multiple chains (#55)
chn[:param]
andchn[:, :param, :]
now both return the same thing, aChains
object containing only:param
.Strings
are now enforced as parameter names. Symbols no longer work as parameter names. (#57)- Added
get_params
, which packages all the parameters in a chain into aNamedTuple
. Used likeget_params(chn)
. (#57) - Added an overload on
get
accepting a keywordsection
, which can be a vector or a single symbol. Works likeget(chn; section = :pooled)
orget(chn; section = [:parameters, :pooled])
. (#57) - All variants of
get
andget_params
accept a keyword argumentflatten
, which can betrue
orfalse
. Ifflatten=true
, the tuple returned will have a flat structure. This is handy if you want to go straight to a dataframe, becauseflatten=false
(the default) will clump variables with the same names together (as with"P[1]", "P[2]", "P[3]"
). (#57) - Fixed bug where chains would not show if their length was less than 200 (c2d0827)
- Fixed bug where chains would not show if they did not contain a
:parameters
section
Plot labl improvements
- Fixed quantile deprecation warning
- Supported label overriding for
plot
- Set default chain name to an integer