bayesplain.core.beta_binomial.posterior

bayesplain.core.beta_binomial.posterior(successes, n, a=1.0, b=1.0)[source]

Exact Beta posterior for an unknown proportion.

With a Beta(a, b) prior and successes out of n observed, the posterior is Beta(a + successes, b + n - successes). That is the whole computation – conjugacy means the prior and posterior are the same family, so observing data just adds counts to the two shape parameters.

Parameters:
successes : int

Number of successes observed.

n : int

Number of trials.

a : float, default 1.0

Shape parameters of the Beta prior. Beta(1, 1) is flat on [0, 1].

b : float, default 1.0

Shape parameters of the Beta prior. Beta(1, 1) is flat on [0, 1].

Returns:

Frozen Beta posterior, supporting .mean(), .ppf(), .rvs() and the rest of the scipy distribution interface.

Return type:

scipy.stats.rv_continuous_frozen

Notes

Because the posterior is available in closed form, quantities like the mean and the equal-tailed interval should be read off analytically rather than estimated from draws. Draws are only needed for quantities built from more than one posterior, such as a difference between two groups.