Premium problem123. Posterior Predictive for the Next Trial

Medium Locked

With a Beta(α,β)\mathrm{Beta}(\alpha,\beta) prior and observed successes and failures, return the probability that the next trial succeeds.

P(next=1)=successes+αsuccesses+failures+α+βP(\text{next} = 1) = \frac{\text{successes} + \alpha}{\text{successes} + \text{failures} + \alpha + \beta}

Note this is the posterior mean, not the MAP. Predicting the next observation averages over the whole posterior rather than committing to its peak, which is why zero successes out of five does not predict zero.

Input

alpha = 1.0
beta = 1.0
successes = 0
failures = 5

Output

0.14285714285714285

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)