Beta distribution is commonly used as a prior distribution in Bayesian statistics, particularly for modeling probabilities that are bounded between 0 and 1. It is characterized by two parameters, alpha and beta, which control the shape of the distribution.

# 1. INTUITION

One way to think about the beta distribution is to consider it as a way of modeling the distribution of probabilities.

For example, let’s say we are flipping a coin and we want to model the probability of getting heads. We know that the probability of getting heads is between 0 and 1, so we can use a beta distribution to model this probability.

The beta distribution has a probability density function (PDF) given by:

where x is a value between 0 and 1, alpha and beta are the shape parameters, and B(alpha, beta) is the beta function, which is used to normalize the PDF. The beta function is defined as:

where Gamma is the gamma function, which is a generalization of the factorial function to non-integer values.

# 2. CONNECTION WITH BINOMIAL DISTRIBUTION

The beta distribution is intimately connected to the binomial distribution. Specifically, if we have a binomial distribution with parameters n (the number of trials) and p (the probability of success on each trial), and we fix n and let p vary between 0 and 1, the distribution of p will be a proportional to a beta distribution with parameters that depend on the number of successes and failures in the binomial distribution.

In other words, if we have some prior beliefs about the probability of success p in a binomial experiment, we can represent those beliefs using a beta distribution. As we collect data and update our beliefs, we can update the beta distribution to obtain a posterior distribution that reflects our updated beliefs.

This connection between the beta and binomial distributions is a powerful tool in Bayesian statistics, and allows us to use the beta distribution as a flexible and intuitive prior distribution for modeling probabilities.

Let’s illustrate this important connection with a a few plots. I will use a sample python code, which you…