Welcome to tarp’s documentation!#

tarp is a small python package for performing statistical coverage tests to assess the quality of posterior estimators.

tarp’s small API is documented below.

tarp.get_drp_coverage(samples, theta, references='random', metric='euclidean')[source]#

Deprecated since version 0.1.0: This will be removed in 0.2.0. Use get_tarp_coverage instead

Return type:

Tuple[ndarray, ndarray]

tarp.get_tarp_coverage(samples, theta, references='random', metric='euclidean', num_alpha_bins=None, num_bootstrap=100, norm=False, bootstrap=False, seed=None)[source]#

Estimates coverage with the TARP method.

Reference: Lemos, Coogan et al 2023

Parameters:
  • samples (ndarray) – the samples to compute the coverage of, with shape (n_samples, n_sims, n_dims).

  • theta (ndarray) – the true parameter values for each samples, with shape (n_sims, n_dims).

  • references (Union[str, ndarray]) – the reference points to use for the DRP regions, with shape (n_references, n_sims), or the string "random". If the later, then the reference points are chosen randomly from the unit hypercube over the parameter space.

  • metric (str) – the metric to use when computing the distance. Can be "euclidean" or "manhattan".

  • num_alpha_bins (Optional[int]) – number of bins to use for the credibility values. If None, then n_sims // 10 bins are used.

  • num_bootstrap (int) – number of bootstrap iterations to perform (Default = 100)

  • norm (bool) – whether to apply or not the normalization (Default = False)

  • bootstrap (bool) – whether to use bootstrap to estimate uncertainties (Default = False)

  • seed (Optional[int]) – the seed to use for the random number generator. If None, then no seed

Return type:

Tuple[ndarray, ndarray]

Returns:

Expected coverage probability (ecp) and credibility values (alpha). If bootstrap is True, the ecp array has an extra dimension corresponding to the number of bootstrap iterations