---
title: "Conjugate priors"
canonical: "https://modelassist.epixanalytics.com/space/EA/26575373/Conjugate%20priors"
format: markdown
---
A conjugate prior has the same functional form in *q* as the likelihood function which leads to a posterior distribution belonging to the same distribution family as the prior. For example, the Beta(*a*<sub>*1*</sub>,*a*<sub>*2*</sub>,1) distribution has probability mass function *f(q)* given by:

![image](media://a98bb18c-e989-4eea-8190-849c85b6c572)

  


<span style="color: #000000">         </span>  


> Macro (mathblock)

  


Note that the two shape parameters of the Beta distribution are called *a*<sub>*1*</sub> and *a*<sub>*2*</sub> here but elsewhere in this document we may also use a and b, or even α and β. Sorry!

The denominator is a constant for particular values of *a*<sub>*1*</sub> and *a*<sub>*2*</sub>, so we can rewrite the equation as:

![image](media://ebdf0ed3-d10e-45c7-883b-4c7a90923f24)

  


<span style="color: #000000"> </span>

> Macro (mathblock)

<span style="color: #000000">                   </span>

<span style="color: #000000">                                                                          (1)</span>

  


<span style="color: #000000">If we had observed </span><span style="color: #000000">*s*</span><span style="color: #000000"> successes in </span><span style="color: #000000">*n*</span><span style="color: #000000"> trials and were attempting to estimate the true probability of success </span><span style="color: #000000">*p*</span><span style="color: #000000">, the likelihood function </span><span style="color: #000000">*l*</span><span style="color: #000000">(</span><span style="color: #000000">*s*</span><span style="color: #000000">,</span><span style="color: #000000">*n*</span><span style="color: #000000">;</span>q<span style="color: #000000">) would be given by the binomial distribution probability mass function written (using</span> *q* <span style="color: #000000">to represent the unknown parameter </span><span style="color: #000000">*p*</span><span style="color: #000000">):</span>

![image](media://27f9ae4d-2dff-4330-aa79-0ae9884cd99f)

  


> Macro (mathblock)

  


<span style="color: #000000">Since the binomial coefficient </span>> Macro (mathinline)

<span style="color: #000000"> is constant for the given data set (i.e. known </span><span style="color: #000000">*n*</span><span style="color: #000000">, </span><span style="color: #000000">*s*</span><span style="color: #000000">), we can rewrite the equation as:</span>

<span style="color: #000000">  </span>

![image](media://c2d680b8-b51f-4ac0-bc4f-d521dbd5bcb1)

  


> Macro (mathblock)

<span style="color: #000000">         </span>

<span style="color: #000000">                                                                            (2)</span>

  


We can see that the Beta distribution and the binomial likelihood function have the same functional form in q, i.e. q <sup>*a*</sup>.(1-q)<sup>*b*</sup>, where *a* and *b* are constants. Since the posterior distribution is a product of the prior and likelihood function, it too will have the same functional form, i.e. combining Equations 1 and 2 we have:

<span style="color: #000000"> </span>

![image](media://fb19247d-70f1-4a2c-aa32-1c690c84a910)

  


> Macro (mathblock)

<span style="color: #000000">  </span>

<span style="color: #000000">                                                                             (3)</span>

  


We know from the form that this is a Beta(*a*<sub>*1*</sub>+*s*, *a*<sub>*2*</sub>+n-s)  distribution, so the posterior density is actually:

![image](media://8f641430-ffb2-41e5-bff6-2bca2e3ea483)

  


<span style="color: #000000">        </span>  


> Macro (mathblock)

  


  


<span style="color: #000000">With a bit of practice, one starts to recognize distributions because of their functional form, without having to go through the step of obtaining the normalized equation. Thus if one uses a Beta distribution as a prior for </span><span style="color: #000000">*p*</span><span style="color: #000000"> with a binomial likelihood function, the posterior distribution is also a Beta. The value of using conjugate priors is that we can avoid actually doing any of the mathematics and get directly to the posterior distribution by simply updating the parameters of the prior distribution. Conjugate priors are often called </span><span style="color: #000000">*convenience priors*</span><span style="color: #000000"> for obvious reasons.</span>

  


The Beta(1, 1, 1) distribution is the same as a Uniform(0, 1) distribution, so if we want to start with a Uniform(0, 1) prior for *p*, which makes intuitive sense and also mathematical sense from the viewpoint of [MaxEnt](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26577311), our posterior distribution is given by Beta(*s*+1, *n*-*s*+1,1). This is a particularly useful result in [modeling binomial processes](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26574972/). The Jeffreys prior for a binomial probability is a Beta(½,½,1), which peaks at zero and one, but holds to one philosophy of an uninformed prior. Some modelers using a Beta(0, 0, 1) prior which is mathematically undefined and therefore meaningless by itself, giving a posterior distribution of Beta(*s*, *n*-*s*) which has a mean of *s*/*n*: in other words it provides an [unbiased](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26586655) estimate for the binomial probability (a property many statisticians prefer), but has a mode of (*s*-1)/(*n*-2) which is not intuitive, and doesn't work if *s*=0 or *n*.

  


The following table lists other conjugate priors and the associated likelihood functions. [Exponential families of distributions](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26576116/), from which one often draws the likelihood function, all have conjugate priors so the technique can be used frequently in practice. Conjugate priors are also often used to provide approximate but very convenient representations to [subjective priors](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575374/).

  


  


| Table of likelihood functions and their conjugate distributions |
| --- |
| ***Likelihood functions*** | ***Information*** | ***Estimated parameter*** | ***Prior*** | ***Posterior*** |
| Multinomial | s<sub>1</sub>,s<sub>2</sub>,..s<sub>k</sub> successes in k categories | Probabilities p<sub>1</sub>,p<sub>2</sub>,..p<sub>k</sub> | Dirichlet(a1,a2,..ak) | ![image](media://882ef62b-32a8-418a-82d4-2e5a8f444f59)<br>> Macro (mathinline) |
| Binomial | *s* successes in *n* trials | Probability *p* | Beta(*a1*,*a2*,1) | ![image](media://738dad48-d666-42ac-aaa7-96f8e62c3034)<br>> Macro (mathinline)<br>> Macro (mathinline) |
| Exponential | *n* "times' *x*<sub>*i*</sub> | mean<sup>-1</sup> = *l* | Gamma(0,*b*,*a*) | ![image](media://80e83ff7-6b7f-4f3d-a345-f6587cb7ca7f)<br>> Macro (mathinline)<br>> Macro (mathinline) |
| Normal (with known *s*) | *n* data values with mean > Macro (mathinline) | Mean *m* | Normal(*m*<sub>*m*</sub>,*s*<sub>*m*</sub>) | ![image](media://be51e17c-9dce-4c93-89bc-c92e5fc52e95)<br>> Macro (mathinline)<br>> Macro (mathinline) |
| Poisson | a observations in time *t* | Mean events per unit time *l* | Gamma(0,*b,a*) | ![image](media://50c2364f-011b-4da0-9ef9-254cd5077a88)<br>> Macro (mathinline)<br>> Macro (mathinline) |

  


  


---