Machine learning papers often mention the term “conjugate prior”. Here is an attempt to provide a practical understanding of the term. What I have realized however is that you can’t just explain conjugate prior without talking about parameter estimation.

Parameter estimation is concerned with estimating the parameters of the underlying distribution of a dataset, hence referred as parameter estimation. For instance if we tossed a coin (we don’t know whether it is biased or not) 10 times and get the following output: . Now let’s say I ask you what’s the probability of getting head in the 11th coin toss. One possible way is to determine the probability of getting head (i.e. ) using the above sample data. This process of estimating a distribution parameter is called parameter estimation. Once we know the value , we can use it predict the probability of getting 11th head (or tail).

There are however two different approaches for parameter estimation: MLE and MAP. Conjugate prior is concerned with the second approach (MAP). However I would suggest to still go through MLE as it provides some of the foundation for MAP.

**Maximum Likelihood Estimation (MLE)
**To understand the idea behind MLE assume that can take any value between 0 and 1 (such as 0.1, 0.2, 0.3, … ). For each value of , we can calculate probability of getting the above dataset X, i.e as follows.

Let’s assume we calculated for each possible value of (which is actually impossible), the question still remains which value of should we select ? A natural choice is to select that gives the highest probability for the dataset, i.e.

In order to avoid the number overflow problem, we take the log sum instead of product of probabilities as shown below

Where represents number of heads and number of tails. Now to maximize the above objective function, we take the partial derivation with respect to and equate it to zero. That is

Solving the above equation, we get . This is our maximum likelihood estimate () of probability of getting head. Notice that is same as the mean formula. Thus, our MLE for probability of getting head () is 0.7.

**Maximum A Posteriori Probability (MAP)**

In the case of MLE, we maximized to estimate . In the case of MAP, we maximize to get the estimate of . An advantage of MAP is that by modeling we can use Bayesian tranformation and use our priori belief to influence estimate of .

Based on Bayes theorem, we can rewrite as

on RHS represents our belief about . For instance, based on our prior experience with other coins we estimate to be around 0.5. However this is just our belief and we are not 100% confident. To model our belief about we need another distribution. Theoretically, we are free to select any distribution, but using some random distribution makes the whole calculation very difficult. Scholars found that if select a distribution for that has the same form as of then the whole computation becomes much easier. In this case, the distribution associated with is known as **conjugate prior**. For bernoulli distribution, the conjugate prior is given by Beta distribution which takes two parameters () and the probability density function of the Beta distribution is given as:

where represents beta function.

For different values of , we get different shapes of beta distribution each of which peaks at .

Thus to model our belief about , we can experiment with different values of and find where maximizes. For now, I just tell this will happen when . Thus, we can rewrite our Bayesian tranformation as

We can simplify the above equation in two ways. First we can get rid of the denominator as it is only for normalization purpose. Second we take the log sum instead of product to avoid the number overflow problem.

As in MLE, now we take the partial derivative of the above equation with respect to and equate it to zero. This will give us the value of that maximizes . Thus,

Since, and , we get .

**Summary**

- MLE maximizes whereas MAP maximizes
- MAP allows to model prior belief about the parameter. As a result, MAP estimates are pulled towards our prior beliefs.

**Reference**

- Avi Kak’s Tutorial on Paramter Estimation: I found this to be one of the best and easy to follow. However before finding this one I already had some good understanding of MLE and MAP and therefore other’s might not find it so intuitive.
- Gregor Heinrich Post on parameter estimation in text analysis.

very helpful. thanks.

You explained it very well , thanks.

How can we find the MAP estimator for the Dirichlet hype-parameters prior and Multinomial Distribution?