---
title: "Taylor series approximation to a Bayesian posterior distribution"
canonical: "https://modelassist.epixanalytics.com/space/EA/26575387/Taylor%20series%20approximation%20to%20a%20Bayesian%20posterior%20distribution"
format: markdown
---
<span style="color: #000000">When we have a reasonable amount of data with which to calculate the likelihood function, the posterior distribution tends to come out looking approximately Normally distributed. In this section we will examine why that is, and provide a shorthand method to determine the approximating Normal distribution directly without needing to go through a complete Bayesian analysis.</span>

 

<span style="color: #000000">Our best estimate</span> *q*<span style="color: #000000">*0*</span> <span style="color: #000000">of the value of a parameter</span> *q* <span style="color: #000000">is the value for which the posterior distribution </span><span style="color: #000000">*f*</span><span style="color: #000000">(</span>*q* <span style="color: #000000">) is at its maximum. Mathematically, this equates to the condition:</span>

 

![image](media://10492b07-24f8-486a-836b-5f992a0a9961)

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


> Macro (mathblock)

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

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

 

<span style="color: #000000">That is to say,</span> *q0* occurs where the gradient of *f*(*q*) is zero. Strictly speaking, we also require that the gradient of *f*(*q*) is going from positive to negative for *q* <sub>*0*</sub> to be a maximum, i.e.:

 

![image](media://64031608-869a-4153-ad73-3981e2f3a37a)

  


> Macro (mathblock)

  


 

<span style="color: #000000">The second condition is only of any importance if the posterior distribution has two or more peaks, for which a Normal approximation to the posterior distribution would be inappropriate anyway. Taking the first and second derivatives of </span><span style="color: #000000">*f(*</span>*q*<span style="color: #000000">*)*</span> <span style="color: #000000">assumes that</span> *q* <span style="color: #000000">is a continuous variable, but the principle applies equally to discrete variables, in which case we are just looking for that value of</span> *q* <span style="color: #000000">for which the posterior distribution has the highest value.</span>

 

The [Taylor series expansion of a function](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26574961/) allows one to produce a polynomial approximation to some function *f(x)* about some value *x*<sub>*0*</sub> that usually has a much simpler form than the original function. The Taylor series expansion says:

 

![image](media://52dfdbcc-395f-4031-b1e0-a2372e830d9d)

 

> Macro (mathblock)

 

where *f(m)(x)* represents the *m*th derivative of *f(x)* with respect to *x*.

 

<span style="color: #000000">To make the next calculation a little easier to manage, we first define the log of the posterior distribution </span><span style="color: #000000">*L(*</span>*q*<span style="color: #000000">*)*</span> <span style="color: #000000">= log</span><sub><span style="color: #000000">e</span></sub><span style="color: #000000">[</span><span style="color: #000000">*f(*</span>*q*<span style="color: #000000">*)*</span><span style="color: #000000">]. Since </span><span style="color: #000000">*L(*</span>*q*<span style="color: #000000">*)*</span> <span style="color: #000000">increases with </span><span style="color: #000000">*f(*</span>*q*<span style="color: #000000">*)*</span> <span style="color: #000000">the maximum of </span><span style="color: #000000">*L(*</span>*q*<span style="color: #000000">*)*</span> <span style="color: #000000">occurs at the same value of</span> *q* <span style="color: #000000">as the maximum of </span><span style="color: #000000">*f(*</span>*q*<span style="color: #000000">*)*</span><span style="color: #000000">. We now apply the Taylor series expansion of </span><span style="color: #000000">*L*</span><span style="color: #000000">(</span>*q*<span style="color: #000000">) about</span> *q*<sub>*0*</sub> <span style="color: #000000">for the first three terms:</span>

 

![image](media://bc9c7aa2-2de2-4cb6-a402-680ca30e328c)

  


> Macro (mathblock)

  


 

<span style="color: #000000">The first term in this expansion is just a constant</span> value (*k*), and <span style="color: #000000">tells us nothing about the shape of </span><span style="color: #000000">*L(*</span>*q*<span style="color: #000000">*)*</span><span style="color: #000000">; the second term equals zero from Equation 1, so we are left with the simplified form:</span>

 

![image](media://b5b953e3-6035-4acf-861e-8e6577e75c22)

  


> Macro (mathblock)

  


 

<span style="color: #000000">This approximation will be good providing the higher order terms (</span><span style="color: #000000">*m*</span><span style="color: #000000"> = 3, 4, etc.) have much smaller values than the </span><span style="color: #000000">*m*</span><span style="color: #000000"> = 2 term here.</span>

 

We can now take the exponential of *L(q)* to get back to *f(q)*:

 

![image](media://cb840a85-245f-4479-ba03-e5174f456179)

  


> Macro (mathblock)

  


 

<span style="color: #000000">where </span><span style="color: #000000">*K*</span><span style="color: #000000"> is a normalizing constant. Now, the Normal(</span>*m*<span style="color: #000000">,</span>*s*<span style="color: #000000">) distribution has probability density function </span><span style="color: #000000">*f(x)*</span><span style="color: #000000"> given by:</span>

![image](media://87c69162-984e-4d92-a017-e42e2d244c93)

  


> Macro (mathblock)

  


 

<span style="color: #000000">Comparing the above two equations, we can see that </span><span style="color: #000000">*f(*</span>*q*<span style="color: #000000">*)*</span> <span style="color: #000000">has the same functional form as a Normal distribution where:</span>

 

![image](media://e1cb5224-9960-43a9-a792-fce7186485b0)

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

<span style="color: #000000">      and         </span>> Macro (mathinline)



 

 

<span style="color: #000000">and we can thus often approximate the Bayesian posterior distribution by the following Normal distribution:</span>

 

![image](media://5fde41f1-c314-4faf-ab9c-1c4458e740c7)

  


> Macro (mathblock)

  


 

<span style="color: #000000">We illustrate this Normal (or quadratic) approximation with a two simple examples:</span>

 

[Normal approximation to the Beta posterior distribution](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575394)

[Bayesian estimate of the mean of a Normal distribution with unknown standard deviation](https://epixanalytics.atlassian.net/wiki/spaces/EA/pages/26575390/)

 

 

 

---