# Solved – How to derive mathematical posterior predictive distribution calculation steps for beta prior and binomial likelihood

I would like to know the mathematical calculation step by step processes with beta prior and binomial likelihood for posterior predictive distribution. Contents

Posterior predictive distribution is original pdf times posterior. It's your predictions on 'more' data, given your current data. But your current data is itself dependent on your prior. So really, it's your predicted 'more' data given you've worked out the posterior. Useful link.

Binomial with beta prior is a conjugate prior with parameters found here

To find the posterior, just group multiply the likelihood of data with prior. For example, Posterior of Binomial with Beta Prior, .i.e. the parameter p of the binomial distribution is itself distributed on the beta distribution, is calculated as:

$$prod_{i=1}^{N}$$ $${N}choose{x_i}$$ $$p^{x_i}(1-p)^{n-x_i}$$ $$frac{1}{B(alpha,beta)}p^{alpha-1}(1-p)^{beta-1}$$

All terms that do not contain p, which is the parameter that is distributed in question, are just constants you can just find the distribution that is proportional to whatever that product equals

$$propto p^{sum_{i=1}^{N} x_i}p^{alpha-1}(1-p)^{sum_{i=1}^{N} n_i-x_i}(1-p)^{beta-1}$$

$$propto p^{(alpha+sum_{i=1}^{N} x_i)-1}(1-p)^{(beta+sum_{i=1}^{N} n_i-x_i)-1}$$

So, posterior distirubtion is propotional to a Beta distribution with parameters, $$alpha=alpha+sum_{i=1}^{N} x_i$$ and $$beta=beta+sum_{i=1}^{N} n_i-x_i$$

Put that as your new prior and times it with your original pdf, except this time you full have to do the integral rather than just saying it's 'proportional to' .i.e. The trick will be to kick everything not related to the parameter out of the intgeral, group the exponents to find out what you have multiply with to cancel the intgeral, find a way to multiply by '1' to get a pdf to cancel the integral.

$$int_{0}^{1}$$ $${n}choose{x}p^x(1-p)^{n-x}$$ $$frac{1}{B(alpha+sum x_i,beta+sum n_i-sum x_i)}$$ $$p^{alpha+sum x_i-1}(1-p)^{beta+sum n_i-sum x_i-1}dp$$

kick everything not p out

$${n}choose{x}frac{1}{B(alpha+sum x_i,beta+sum n_i-sum x_i)}$$ $$int_{0}^{1}p^x(1-p)^{n-x}p^{alpha+sum x_i-1}(1-p)^{beta+sum n_i-sum x_i-1}dp$$

Group the exponents in the integral.

$$int_{0}^{1}p^{x+alpha+sum x_i-1}$$ $$(1-p)^{n-x+beta+sum n_i-sum x_i-1}dp$$

Do a trick where you multiply by '1' in the form of $$frac{B(x+alpha+sum x_i,n-x+beta+sum n_i-sum x_i)}{B(x+alpha+sum x_i,n-x+beta+sum n_i-sum x_i)}$$

The inside will resolve to another beta distribution and hence integrating over its range is simply 1.

So that just leaves the outside. $${n}choose{x}frac{B(x+alpha+sum x_i,n-x+beta+sum n_i-sum x_i)}{B(alpha+sum x_i,beta+sum n_i-sum x_i)}$$

This is kind of cheating but that function is a pmf–the beta-binomial pmf where $$n=n$$, $$k=x$$ , $$alpha=alpha+sum x_i$$ , $$beta=beta+sum n_i-sum x_i$$

Rate this post