Maximum Likelihood Estimation
GitHub repository
In this Jupyter notebook, we will do the maximum likelihood estimation of the parameters, mean and standard deviation, of the normal distribution.
Likelihood Functionβ
PDF of normal distribution is given as follows:
f X ( x ) = 1 2 Ο Ο 2 β
e β 1 2 ( x β ΞΌ Ο ) 2 , f_X(x)=\frac{1}{\sqrt{2\pi\sigma^2}}\cdot e^{-\frac{1}{2} (\frac{x-\mu}{\sigma})^2}, f X β ( x ) = 2 Ο Ο 2 β 1 β β
e β 2 1 β ( Ο x β ΞΌ β ) 2 ,
where ΞΌ \mu ΞΌ is mean and Ο \sigma Ο is standard deviation.
Assuming we have a dataset comprising n n n randomly selected observations from a normal distribution with a mean of 155 and a standard deviation of 7, independently and identically distributed (IID). The likelihood function corresponding to these n n n observations is given as follows:
L ( ΞΌ , Ο , x 1 , x 2 , β― β , x n ) = β i = 1 n f X ( x i ) = β i = 1 n 1 2 Ο Ο 2 β
e β 1 2 ( x i β ΞΌ Ο ) 2 = ( 1 2 Ο Ο 2 ) n β
e β 1 2 Ο 2 β i = 1 n ( x i β ΞΌ ) 2 . \begin{align*}
L(\mu,\sigma, x_1, x_2,\cdots,x_{n})&=\prod_{i=1}^{n}f_X(x_i)\\
&=\prod_{i=1}^{n}\frac{1}{\sqrt{2\pi\sigma^2}}\cdot e^{-\frac{1}{2} (\frac{x_i-\mu}{\sigma})^2}\\
&=\Bigg(\frac{1}{\sqrt{2\pi\sigma^2}}\Bigg)^n\cdot e^{-\frac{1}{2\sigma^2} \sum_{i=1}^{n} (x_i-\mu)^2}.\\
\end{align*} L ( ΞΌ , Ο , x 1 β , x 2 β , β― , x n β ) β = i = 1 β n β f X β ( x i β ) = i = 1 β n β 2 Ο Ο 2 β 1 β β
e β 2 1 β ( Ο x i β β ΞΌ β ) 2 = ( 2 Ο Ο 2 β 1 β ) n β
e β 2 Ο 2 1 β β i = 1 n β ( x i β β ΞΌ ) 2 . β
Log Likelihood Functionβ
Taking the log of Likelihood Function, we get
l ( ΞΌ , Ο , x 1 , x 2 , β― β , x n ) = log β‘ [ L ( ΞΌ , Ο , x 1 , x 2 , β― β , x n ) ] = log β‘ [ ( 1 2 Ο Ο 2 ) n β
e β 1 2 Ο 2 β i = 1 n ( x i β ΞΌ ) 2 ] = log β‘ [ ( 1 2 Ο Ο 2 ) n ] β
log β‘ [ e β 1 2 Ο 2 β i = 1 n ( x i β ΞΌ ) 2 ] = β n log