beetroots.inversion.results.utils.mc_utils package

Submodules

beetroots.inversion.results.utils.mc_utils.ess module

implementation of ESS computation, from Gelman et al. [2015]

Original implementation : https://github.com/jwalton3141/jwalton3141.github.io/blob/master/assets/posts/ESS/rwmh.py

Corresponding post : https://jwalton.info/Efficient-effective-sample-size-python/

beetroots.inversion.results.utils.mc_utils.ess.compute_ess(Theta: ndarray) float[source]

Computes the effective sample size of estimand of interest for one physical parameter \(\theta_{nd}\). Vectorized implementation.

Parameters:

Theta (np.ndarray of shape (m_chains, n_iters)) – values of the n_iters iterates for each of the m_chains Markov chains associated to one physical parameter \(\theta_{nd}\)

Returns:

ESS for physical parameter \(\theta_{nd}\)

Return type:

float

beetroots.inversion.results.utils.mc_utils.ess.gelman_rubin(Theta: ndarray) float[source]

Estimates the marginal posterior variance. Vectorized implementation.

Parameters:

Theta (np.ndarray of shape (m_chains, n_iters)) – values of the n_iters iterates for each of the m_chains Markov chains associated to one physical parameter \(\theta_{nd}\)

Returns:

marginal posterior variance

Return type:

float

beetroots.inversion.results.utils.mc_utils.histograms module

beetroots.inversion.results.utils.mc_utils.histograms.plot_1D_chain(list_Theta_lin_nd: ndarray, n: int | None, d: int, folder_path: str, title: str, lower_bounds_lin: ndarray | None, upper_bounds_lin: ndarray | None, N_MCMC: int, T_MC: int, T_BI: int, true_val: float | None = None, is_u: bool = False) None[source]
beetroots.inversion.results.utils.mc_utils.histograms.plot_1D_hist(list_Theta_lin_seed: ndarray, n: int | None, d: int, folder_path: str, title: str, lower_bounds_lin: ndarray | None, upper_bounds_lin: ndarray | None, seed: int | None = None, estimator: float | None = None, IC_low: float | None = None, IC_high: float | None = None, true_val: float | None = None)[source]
beetroots.inversion.results.utils.mc_utils.histograms.plot_2D_chain(list_Theta_lin_seed: ndarray, n: int, d1: int, d2: int, model_name: str, seed: int, folder_path: str, list_names: list, Theta_estimator: ndarray, Theta_true: ndarray | None = None)[source]
beetroots.inversion.results.utils.mc_utils.histograms.plot_2D_hist(list_Theta_lin_seed: ndarray, n: int | None, d1: int, d2: int, model_name: str, folder_path: str, list_names: list, lower_bounds_lin: ndarray, upper_bounds_lin: ndarray, Theta_MMSE: ndarray, true_val: ndarray | None = None, seed: int | str = 'overall', point_challenger: Dict = {})[source]
beetroots.inversion.results.utils.mc_utils.histograms.plot_2D_proba_contours(list_Theta_lin_seed: ndarray, n: int | None, d1: int, d2: int, model_name: str, folder_path: str, list_names: list, lower_bounds_lin: ndarray, upper_bounds_lin: ndarray, Theta_MMSE: ndarray, true_val: ndarray | None = None, seed: int | str = 'overall', point_challenger: Dict = {})[source]

plots the 2D contours of the 68% and 95% high probability regions

inspired from https://stackoverflow.com/questions/37890550/python-plotting-percentile-contour-lines-of-a-probability-distribution

Module contents