 So in this example, we're looking at having, we've already observed n observations or in samples from a Poisson distribution. We've been using a conjugate prior, which is a gamma prior for the rate mu. So here's our gamma prior. We would like the predictive density. In a previous piece of work, we have already found that the posterior distribution g of mu given our data y1 to yn is v plus n, where n is our number, r plus the sum of y, mu to the r plus the sum of y minus 1, e to the minus n plus v mu over the gamma function of r plus the sum of yi. So we have part of our distribution to calculate f of yn plus 1. So the next observation, given our previous observations, we integrate over the relevant range, which here is from 0 to infinity of f of yn plus 1 given mu times g of mu given our previous data and d mu. So by doing this, we separate into two components. This bit here is a Poisson distribution. So we break it into the two relevant bits. So it's the integral from 0 to infinity of, and we think about it in terms of our Poisson data. So we have e to the minus mu mu to the y of the n plus 1 of the distribution. And we have y n plus 1 factorial. So that's this part of our function. And then we include this part of our function times v plus n to the r plus the sum from i equals 1 to n of yi mu to the r plus the sum from i equals 1 to n of yi minus 1, e to the minus n plus v mu over the gamma function of r plus the sum from i equals 1 to n yi. d mu. We take everything that doesn't depend on mu outside of our integral because it's just a constant. So we say it's this part here doesn't depend on mu. So v plus n to the power r plus the sum of yi, i equals 1 up to n, yn plus 1 factorial. And then this bit here also doesn't depend on mu. So the gamma function of r plus the sum of yi, i equals 1 up to n. Then we have the integral from 0 up to infinity of everything that depends on n or mu and we group them together. So let's group them together first in terms of mu to the power of and we have here r plus the sum from i equals 1 to n yi plus yn plus 1 minus 1. So that takes care of this term and this term. Now we have this term and this term. So we have e to the minus n plus v plus 1 mu d mu. And we note that this is the exact same functional form as a gamma function up here or a gamma function up here. We go back up here and we say we note that the integral from 0 to infinity of v to the or mu to the or minus 1 e to the minus v mu over the gamma function of r is equal to 1 because it is a probability distribution. We would note then that v or the integral over mu to the or minus 1 e to the minus v times mu is equal to the gamma function of r divided by v to the power of r. We use the same principle down here to calculate this integral without doing any really horrible integration. So we say it's v plus n to the power of r plus the sum over i from y to 1 to n of yi yn plus 1 factorial the gamma function of r plus the sum of yi. And then we have mu to something minus 1 e to minus something to times mu d mu. So it's the same functional form so we use what we've learned from previously and it's the gamma function of r plus the sum i equals 1 to n yi plus yn plus 1. And we be quite careful here and we divide that by what our equivalent of v was this time which is n plus v plus 1 to the power of r plus the sum of yi plus yn plus 1. And that's your integration done out. Now by grouping this cleverly and if we constrain or to be an integer for simplicity, so if we look at the special case, first of all we'll do the grouping. So we'll say this is v plus n over n plus v plus 1 to the power of r plus the sum of yi. Then we have one more of these, we have this bit left over so 1 over n plus v plus 1 to the power of yn plus 1. And then we have the gamma function of r plus the sum of yi plus yn plus 1 over yn plus 1 factorial. The gamma function of r plus the sum of yi. Now if we constrain to the special case of if r is a specifically non-negative integer, then what we have, we note that a factorial equals the gamma function of a plus 1 by definition for a an integer and greater than 0. So what we have here is the gamma function of r plus the sum yi plus n plus 1. This is i equal to 1 to n is equal to, divided by yn plus 1 factorial gamma function of r plus the sum of yi. Well that's equal to, we think about this one is equal to r plus the sum of plus n plus 1 minus 1 factorial over yn plus 1 factorial and r plus the sum yi minus 1 factorial. And this is equal to n plus the sum of yi plus yn plus 1 minus 1, choose yn plus 1. So in the case where r is an integer, we have the resulting fn plus 1 given our data y up to n is equal to r plus the sum of yi plus yn plus 1 minus 1, choose yn plus 1, 1 over n plus v plus 1 to the power of yn plus 1 times v plus n over n plus v plus 1 to the power of plus this yi. And this because r is an integer is a negative binomial, so we say that yn plus 1 is negative binomial and we have r plus the sum of yi 1 over e plus n plus 1. So you can see that the posterior predictive distribution simplifies down to a negative binomial in the case where your r is specified in your prior was an integer.