mcmcplot package¶
mcmcplot.mcmatplot module¶
Created on Wed Jan 31 12:54:16 2018
@author: prmiles
-
mcmcplot.mcmatplot.
plot_chain_metrics
(chain, name=None, settings=None, return_settings=False)[source]¶ Plot chain metrics for individual chain
Scatter plot of chain
Histogram of chain
-
mcmcplot.mcmatplot.
plot_chain_panel
(chains, names=None, settings=None, skip=1, maxpoints=500, return_settings=False)[source]¶ Plot sampling chain for each parameter
- Args:
chains (
ndarray
): Sampling chain for each parameter
- Kwargs:
names (
list
): List of strings - name of each parametersettings (
dict
): Settings for features of this method.skip (
int
): Indicates step size to be used when plotting elements from the chainmaxpoints (
int
): Max number of display points - keeps scatter plot from becoming overcrowdedreturn_settings (
bool
): Flag to return figure settings. Default: False
- Returns:
If return_settings=True, (
tuple
): (figure handle, settings actually used in program)Otherwise, figure handle
-
mcmcplot.mcmatplot.
plot_density_panel
(chains, names=None, settings=None, return_kde=False, hist_on=False, return_settings=False)[source]¶ Plot marginal posterior densities
- Args:
chains (
ndarray
): Sampling chain for each parameter
- Kwargs:
names (
list
): List of strings - name of each parameter. Default: Nonesettings (
dict
): Settings for features of this method. Default: Nonereturn_kde (
bool
): Flag to return handles of functions from KDE. Default: Falsereturn_settings (
bool
): Flag to return figure settings. Default: Falsehist_on (
bool
): Flag to include histogram on plot with marginal distribution.
- Returns:
-
mcmcplot.mcmatplot.
plot_histogram_panel
(chains, names=None, settings=None, return_settings=False)[source]¶ Plot histogram from each parameter’s sampling history
-
mcmcplot.mcmatplot.
plot_pairwise_correlation_panel
(chains, names=None, settings=None, skip=1, maxpoints=500, return_settings=False)[source]¶ Plot pairwise correlation for each parameter
- Args:
chains (
ndarray
): Sampling chain for each parameter
- Kwargs:
names (
list
): List of strings - name of each parametersettings (
dict
): Settings for figure features made by this method.skip (
int
): Indicates step size to be used when plotting elements from the chainmaxpoints (py:class:int): Maximum allowable number of points in plot.
return_settings (
bool
): Flag to return figure settings. Default: False
- Returns:
If return_settings=True, (
tuple
): (figure handle, settings actually used in program)Otherwise, figure handle
mcmcplot.mcseaborn module¶
Created on August 5, 2018
@author: prmiles
-
mcmcplot.mcseaborn.
plot_joint_distributions
(chains, names=None, settings=None, maxpoints=500, skip=1, return_settings=False)[source]¶ Plot joint distribution for each parameter set.
https://seaborn.pydata.org/generated/seaborn.jointplot.html
- Args:
chains (
ndarray
): Sampling chain for each parameter
- Kwargs:
names (
list
): List of strings - name of each parameter. Default: Nonesettings (
dict
): Settings for features of this method. Default: Noneskip (
int
): Indicates step size to be used when sampling elements from the chain. Default: 1maxpoints (
int
): Max number of sample points - keeps generation of KDE shorter. Default: 500return_settings (
bool
): Flag to return figure settings. Default: False
- Returns:
If return_settings=True, (
tuple
): (figure handle, settings actually used in program)Otherwise, figure handle
-
mcmcplot.mcseaborn.
plot_paired_density_matrix
(chains, names=None, index=None, settings=None, return_settings=False)[source]¶ Plot paired density matrix.
mcmcplot.utilities module¶
Created on Mon May 14 06:24:12 2018
@author: prmiles
-
mcmcplot.utilities.
append_to_nrow_ncol_based_on_shape
(sh, nrow, ncol)[source]¶ Append to list based on shape of array
-
mcmcplot.utilities.
check_settings
(default_settings, user_settings=None)[source]¶ Check user settings with default.
Recursively checks elements of user settings against the defaults and updates settings as it goes. If a user setting does not exist in the default, then the user setting is added to the settings. If the setting is defined in both the user and default settings, then the user setting overrides the default. Otherwise, the default settings persist.
-
mcmcplot.utilities.
check_symmetric
(a, tol=1e-08)[source]¶ Check if array is symmetric by comparing with transpose.
-
mcmcplot.utilities.
extend_names_to_match_nparam
(names, nparam)[source]¶ Append names to list using default convention until length of names matches number of parameters.
For example, if names = [‘name_1’, ‘name_2’] and nparam = 4, then two additional names will be appended to the names list. E.g.,:
names = ['name_1', 'name_2', '$p_{2}$', '$p_{3}$']
-
mcmcplot.utilities.
gaussian_density_function
(x, mu=0, sigma2=1)[source]¶ Standard normal/Gaussian density function.
-
mcmcplot.utilities.
generate_default_names
(nparam)[source]¶ Generate generic parameter name set.
For example, if nparam = 4, then the generated names are:
names = ['$p_{0}$', '$p_{1}$', '$p_{2}$', '$p_{3}$']
-
mcmcplot.utilities.
generate_ellipse
(mu, cmat, ndp=100)[source]¶ Generates points for a probability contour ellipse
-
mcmcplot.utilities.
generate_ellipse_plot_points
(x, y, ndp=100)[source]¶ Generates points for a probability contour ellipse for 2 columns of chain
-
mcmcplot.utilities.
generate_names
(nparam, names)[source]¶ Generate parameter name set.
For example, if nparam = 4, then the generated names are:
names = ['p_{0}', 'p_{1}', 'p_{2}', 'p_{3}']
-
mcmcplot.utilities.
generate_subplot_grid
(nparam=2)[source]¶ Generate subplot grid.
For example, if nparam = 2, then the subplot will have 2 rows and 1 column.
-
mcmcplot.utilities.
is_semi_pos_def_chol
(x)[source]¶ Check if matrix is semi positive definite by calculating Cholesky decomposition.
- Args:
x (
ndarray
): Matrix to check
- Returns:
If matrix is not semi positive definite return
False, None
If matrix is semi positive definite return
True
and the Upper triangular form of the Cholesky decomposition matrix.
-
mcmcplot.utilities.
make_x_grid
(x, npts=100)[source]¶ Generate x grid based on extrema.
1. If len(x) > 200, then generates grid based on difference between the max and min values in the array.
2. Otherwise, the grid is defined with respect to the array mean plus or minus four standard deviations.
-
mcmcplot.utilities.
setup_subsample
(skip, maxpoints, nsimu)[source]¶ Setup subsampling from posterior.
When plotting the sampling chain, it is often beneficial to subsample in order to avoid to dense of plots. This routine determines the appropriate step size based on the size of the chain (nsimu) and maximum points allowed to plot (maxpoints). The function checks if the size of the chain exceeds the maximum number of points allowed in the plot. If yes, skip is defined such that every the max number of points are used and sampled evenly from the start to end of the chain. Otherwise the value of skip is return as defined by the user. A subsample index is then generated based on the value of skip and the number of simulations.