Module Documentation¶
emcwrap.sampler¶
- emcwrap.sampler.get_prior_sample(frozen_prior, nsamples, check_func=False, seed=None, mapper=<class 'map'>, filterwarnings='error', max_attempts=10, debug=False, verbose=True)¶
Get a sample of size nsamples from the prior distribution.
- emcwrap.sampler.mcmc_summary(chain, lprobs, priors, acceptance_fraction=None, out=<built-in function print>, **args)¶
- emcwrap.sampler.run_mcmc(lprob, nsteps=None, p0=None, moves=None, stopping_weight=None, priors=None, prior_transform=None, backend=None, update_freq=False, resume=False, pool=None, report=None, description=None, temp=1, maintenance_interval=False, verbose=True, **kwargs)¶
Run the emcee sampler.
emcwrap.moves¶
emcwrap.tools¶
- emcwrap.tools.get_bijective_prior_transformation(funcs_con, funcs_re)¶
Get the bijective prior transformation function.
- emcwrap.tools.get_log_prior(frozen_prior)¶
Get the log-prior function.
- emcwrap.tools.get_prior(prior, verbose=False)¶
Compile prior-related computational objects from a list of priors.
- emcwrap.tools.load_backend(backend)¶
just a shortcut
- emcwrap.tools.map2arr(iterator)¶
Function to cast result from map to a tuple of stacked results
By default, this returns numpy arrays. Automatically checks if the map object is a tuple, and if not, just one object is returned (instead of a tuple). Be warned, this does not work if the result of interest of the mapped function is a single tuple.
- Parameters:
iterator (iter) – the iterator returning from map
- Returns:
numpy array (optional
- Return type:
list)
- emcwrap.tools.parse_yaml(mfile)¶
parse from yaml file
- emcwrap.tools.remove_backend(backend)¶
just a shortcut
- emcwrap.tools.rm_backend(backend)¶
just a shortcut
- emcwrap.tools.save_to_backend(backend, content)¶
emcwrap.plots¶
- emcwrap.plots.fast_kde(x, bw=4.5)¶
A fft-based Gaussian kernel density estimate (KDE) The code was adapted from https://github.com/mfouesneau/faststats
- Parameters:
x (Numpy array or list) –
bw (float) – Bandwidth scaling factor for the KDE. Should be larger than 0. The higher this number the smoother the KDE will be. Defaults to 4.5 which is essentially the same as the Scott’s rule of thumb (the default rule used by SciPy).
- Returns:
density (A gridded 1D KDE of the input points (x))
xmin (minimum value of x)
xmax (maximum value of x)
- emcwrap.plots.get_axis(ax, default_rows, default_columns, **default_kwargs)¶
Verifies the provided axis is of the correct shape, and creates one if needed.
- Parameters:
ax – matplotlib axis or None
default_rows – int, expected rows in axis
default_columns – int, expected columns in axis
**default_kwargs – keyword arguments to pass to plt.subplot
- Returns:
axis, or raises an error
- emcwrap.plots.kdeplot_op(ax, data, bw, prior=None, prior_alpha=1, prior_style='--')¶
Get a list of density and likelihood plots, if a prior is provided.
- emcwrap.plots.plot_posterior_op(trace_values, ax, bw, prior, kde_plot=False, point_estimate='mean', round_to=3, alpha_level=0.05, ref_val=None, rope=None, text_size=16, display_additinal_info=False, **kwargs)¶
Artist to draw posterior.
- emcwrap.plots.posteriorplot(trace, varnames=None, tune=0, figsize=None, plots_per_fig=4, text_size=None, ropep=None, ref_val=None, round_to=3, alpha_level=0.05, bw=4.5, ax=None, **kwargs)¶
- emcwrap.plots.scale_text(figsize, text_size)¶
Scale text to figsize.
- emcwrap.plots.traceplot(trace, varnames, tune, figsize=None, plots_per_fig=3, frozen_prior=None, draw_each_trace=True, bw=4.5, text_size=None, **kwargs)¶
emcwrap.stats¶
- emcwrap.stats.calc_min_interval(x, alpha)¶
Internal method to determine the minimum interval of a given width
Assumes that x is sorted numpy array.
- emcwrap.stats.gelman_rubin(sample)¶
The Gelman-Rubin (1992) statistics.
- emcwrap.stats.integrated_time(x)¶
- emcwrap.stats.logpdf(drv, cmean, ccov)¶
- emcwrap.stats.mc_error(x)¶
- emcwrap.stats.mdd_harmonic_mean(chain, lprobs, pool=None, alpha=0.05, verbose=False, debug=False)¶
Approximate the marginal data density useing modified harmonic mean.
- emcwrap.stats.mdd_laplace(chain, lprobs, calc_hess=False)¶
Approximate the marginal data density useing the LaPlace method.
- emcwrap.stats.summary(priors, store, pmode=None, bounds=None, alpha=0.1, top=None, show_prior=True)¶
emcwrap.dists¶
- class emcwrap.dists.InvGammaDynare(*args: Any, **kwargs: Any)¶
Bases:
rv_continuous- name = 'inv_gamma_dynare'¶
- emcwrap.dists.inv_gamma_spec(mu, sigma)¶