infer_bernoulli_bayes¶
-
Python_modules.mmcomplexity.
infer_bernoulli_bayes
(num_successes, num_trials, beta_prior=(1, 1))¶ Given
num_trials
independent observations from a Bernoulli random variable withnum_successes
successes, returns the posterior distribution over the Bernoulli parameter in the form of a Beta distribution. May take hyperparameters of a Beta distribution for the prior.To compute the posterior, the sufficient statistics are updated.
- Args:
num_successes (int): number of successes num_trials (int): number of observations beta_prior (tuple): corresponds to the usual parameters of a Beta distribution, a and b (or alpha, beta)
defaults to (1,1), which is a flat prior
- Raises:
ValueError: if num_trials < num_successes or a hyperparameter is negative or num_trials < 0
- Returns:
- scipy.stats.beta: frozen distribution, see
doc.