bayesplain.core.dirichlet_multinomial.log_bayes_factor_goodness_of_fit

bayesplain.core.dirichlet_multinomial.log_bayes_factor_goodness_of_fit(counts, expected_shares, concentration=1.0)[source]

Log Bayes factor for “the shares are unknown” against fixed shares.

Under the null the category probabilities are exactly expected_shares; under the alternative they are Dirichlet(a). Both marginal likelihoods are closed form and the multinomial coefficient cancels, leaving

\[\log \mathrm{BF}_{10} = \log \mathcal{D}(a + n) - \log \mathcal{D}(a) - \sum_j n_j \log p_{0j}\]
Parameters:
counts : array_like

Count in each category.

expected_shares : array_like

Shares under the null. Normalised to sum to one.

concentration : float or array_like, default 1.0

Dirichlet concentration under the alternative.

Returns:

log(BF10).

Return type:

float

Examples

With two categories this is the Beta-binomial point-null Bayes factor:

>>> from bayesplain.core import beta_binomial
>>> a = log_bayes_factor_goodness_of_fit([34, 186], [0.1, 0.9])
>>> b = beta_binomial.log_bayes_factor_point_null(34, 220, 0.1, 1.0, 1.0)
>>> bool(abs(a - b) < 1e-9)
True