mixle.utils.pvalues module

binomial_rank(log_p_vec, log_p1_vec=None, count_vec=None, ll_eps=1.0e-4, max_len=None)[source]

Approximates the log-density histogram for a composite of binomials.

x, y, (LL0, DLL, cnt) = binomial_rank(np.log([0.3, 0.2]), count_vec=[3, 2], max_len=10000)

# p_mat([1, 0, 0, 1, 1]) LL = np.log([0.3, 0.7, 0.7, 0.2, 0.2]).sum() approx_rank = y[int((LL - LL0)/DLL):].sum() * np.power(2.0, cnt)

rtype(Tuple[np.ndarray, np.ndarray, Tuple[float, float, float]])

Parameters:
  • log_p_vec (list[float] | ndarray) – Vector with log probabilities for each binomial distribution

  • log_p1_vec (list[float] | ndarray | None) – Optional vector with log one minus probabilities for each binomial distribution (for high-precision)

  • count_vec (list | ndarray | None) – Vector with the number of draws for each binomial distribution

  • ll_eps (float) – Bin spacing is determined so that |LL - floor(LL/space)*space| < ll_eps

  • max_len (int | None) – Maximum number of bins for histogram

Returns:

log_density array, corresponding probs array, Tuple[ll0, dll, total_count]

Return type:

tuple[ndarray, ndarray, tuple[float, float, float]]