Skip to content

Latest commit

 

History

History
92 lines (64 loc) · 1.57 KB

statsplots.md

File metadata and controls

92 lines (64 loc) · 1.57 KB

StatsPlots.jl

MCMCChains implements many functions for plotting via StatsPlots.jl.

Simple example

The following simple example illustrates how to use Chain to visually summarize a MCMC simulation:

using MCMCChains
using StatsPlots

# Define the experiment
n_iter = 100
n_name = 3
n_chain = 2

# experiment results
val = randn(n_iter, n_name, n_chain) .+ [1, 2, 3]'
val = hcat(val, rand(1:2, n_iter, 1, n_chain))

# construct a Chains object
chn = Chains(val, [:A, :B, :C, :D])

# visualize the MCMC simulation results
plot(chn; size=(840, 600))
# This output is used in README.md too. # hide
filename = "default_plot.svg" # hide
savefig(filename); nothing # hide

Default plot for Chains \

plot(chn, colordim = :parameter; size=(840, 400))


Note that the plot function takes the additional arguments described in the Plots.jl package.

Mixed density

plot(chn, seriestype = :mixeddensity)

Or, for all seriestypes, use the alternative shorthand syntax:

mixeddensity(chn)

Trace

plot(chn, seriestype = :traceplot)
traceplot(chn)

Running average

meanplot(chn)

Density

density(chn)

Histogram

histogram(chn)

Autocorrelation

autocorplot(chn)

Corner

corner(chn)