How to use Bayesian updating to measure deviation from initial estimates and how delayed a Scrum project is? Imagine a Product Owner estimates that the software development team using Scrum they are working with is going to be able to complete 80 user stories in 5 sprints:

*

*Sprint 1: 16 stories

*Sprint 2: 16 stories

*Sprint 3: 16 stories

*Sprint 4: 16 stories

*Sprint 5: 16 stories

Based on past team performance metrics, the team Product Owner has stated a belief that there is only a 5% chance the team will need more sprints to complete those 80 stories.
But after the first 3 sprints, things look like this:

*

*Sprint 1: 8 stories

*Sprint 2: 8 stories

*Sprint 3: 12 stories

Is there a way to use Bayes rule to update the original idea that there was only a 5% chance that the 80 stories will be finished on after the 5th sprint? What is the chance now? Would it had been possible to calculate it after the first sprint differed from the estimate?
Assuming sprints behave as they have behaved in the past... What is the way to calculate the number of sprints that are needed to finish the project so that there is only a 5% chance that more sprints are needed?
 A: There's a simple solution assuming the conjugate Poisson-Gamma model. Sprints have fixed lengths, you are counting the number of done stories per those intervals, so this can be modeled using the Poisson distribution. Gamma is a conjugate prior for Poisson, so if your counts $X_1, X_2, \dots, X_n$ from $n$ sprints follow the Poisson distribution with unknown rate $\lambda$
$$
X_i \sim \mathcal{P}(\lambda)
$$
then you can assume the Gamma prior for $\lambda$ with hyperparameters $\alpha$ for the count assumed a priori $16 \times 5$ and $\beta$ for the assumed number of sprints $5$. In such a case, the posterior distribution for $\lambda$ follows the Gamma distribution
$$\begin{align}
\alpha' &= \alpha + \sum_{i=1}^n X_i \\
\beta' &= \beta+n \\
\lambda &\sim \mathcal{G}\big(\alpha',~\beta'\big)
\end{align}\tag{1}$$
with expected value
$$
E[\lambda] = \frac{\alpha'}{\beta'} = \frac{16 \times 5 + 8 + 8 + 12}{5 + 3} = 13.5
$$
But that's "on average", while you are interested in the posterior predictive distribution of the $X_i$ counts, that is negative binomial with parameters
$$
\tilde X | X_1,X_2,\dots,X_n \sim \mathcal{NB}\big(\alpha', \tfrac{\beta'}{1+\beta'} \big)
$$
It has the same mean as the posterior, but a bigger variance. To learn the upper and lower bounds, just check the quantile function.
> qnbinom(c(0.05, 0.5, 0.95), (16 * 5 + 8 + 8 + 12), (5 + 3)/(1 + 5 + 3))
[1]  7 13 20

There's 5% chance that the team would be doing not more than 5 stories per spring and 95% chance that it would be no more than 20 stories, with the median and average around 13 stories. If you need to do 80 stories, this gives between 4 and 11 sprints:
> 80 / qnbinom(c(0.05, 0.5, 0.95), (16 * 5 + 8 + 8 + 12), (5 + 3)/(1 + 5 + 3))
[1] 11.428571  6.153846  4.000000

Given the simple update rule (1) between previous estimates $\alpha, \beta$, and the newly observed counts, this can be updated each time the new data arrives.
Finally, with statistical software, you can easily run a Monte Carlo simulation to find out what is the chance that you'll manage to the 80 stories in 5 sprints, by simulating the five draws from the negative binomial distribution.
> mean(replicate(100000, sum(rnbinom(5, (16 * 5 + 8 + 8 + 12), (5 + 3)/(1 + 5 + 3))) >= 80))
[1] 0.0868

and it's around 9%.
As you can see, most of the math is rather straightforward and things like expected values can be calculated using pen and paper, but for the quartiles (the worst 5% case) you would need statistical software.
