In our previous lesson, we established the philosophical and practical differences between the frequentist and Bayesian approaches to parameter estimation. We introduced Maximum Likelihood Estimation (MLE) as the cornerstone of the frequentist school, where the goal is to find the parameter values that make our observed data most probable.
Today, we transition from concept to practice. Your objective for this lesson is to derive the Maximum Likelihood Estimation (MLE) for the parameters of a Gaussian (or Normal) distribution. This is a classic and fundamental derivation in machine learning. Given your background in electronics and communication engineering, you're undoubtedly familiar with the Gaussian distribution for modeling noise; here, you'll see the rigorous process for fitting such a model to data from first principles. This exercise perfectly aligns with your goal of connecting mathematical theory to practical application, as the results we derive are the very foundation of common statistical functions you've likely used in your data science work.
The Goal: Finding the "Best" Gaussian
Imagine you have a set of data points, and you hypothesize they were drawn from some Gaussian distribution. The problem is, you don't know which one. A Gaussian distribution is defined by two parameters: its mean (), which sets its center, and its variance (), which controls its spread. Our task is to find the specific values of and that define the single Gaussian curve that best fits our data.
The principle of maximum likelihood gives us a precise way to define "best fit." We want to find the parameters that maximize the likelihood function. The image below provides the intuition for this. Given a histogram of data, we can imagine overlaying many different Gaussian probability density functions (PDFs). MLE is the process of finding the one curve (the green one) for which the likelihood of observing our data is at its peak.

The MLE Derivation: Recipe and Walkthrough
To find the parameters that maximize the likelihood function, we follow a standard four-step mathematical recipe:
- Write the Likelihood Function: Assume the data points are independent and identically distributed (IID), and write the joint probability of the entire dataset as a function of the parameters. This is the product of the individual probabilities.
- Take the Log-Likelihood: Take the natural logarithm of the likelihood function. This turns the product into a sum, which is much easier to differentiate. Since the logarithm is a monotonically increasing function, maximizing the log-likelihood is equivalent to maximizing the original likelihood.
- Take Partial Derivatives: Calculate the partial derivative of the log-likelihood function with respect to each parameter you want to estimate (in our case, and ).
- Solve: Set the derivatives equal to zero and solve the resulting system of equations. The solutions will be your maximum likelihood estimates.
The following video from StatQuest provides an exceptionally clear, step-by-step walkthrough of this entire process. While it's detailed, we'll focus on the core mathematical segments.
Maximum Likelihood For the Normal Distribution, step-by-step!!!
This video, "Maximum Likelihood For the Normal Distribution, step-by-step!!!", will guide us through the entire derivation visually and methodically.
Please watch the following segments carefully: First, watch the setup from calculating the joint likelihood to understand how the likelihood for multiple data points is constructed. Next, focus on the critical step of creating the log-likelihood function from log-likelihood transformation. Pay close attention to how the log rules simplify the complex product into a manageable sum. Then, see how the partial derivative with respect to the mean is calculated: Derivative for μ. Follow this with the partial derivative for the standard deviation: Derivative for σ. Finally, watch the conclusion where these derivatives are set to zero to find the final estimates: Solving the equations.
Formalizing the Derivation
The StatQuest video provided a fantastic intuition and visual guide. Now, let's solidify that understanding by laying out the mathematical steps formally. This will serve as a concise reference for the derivation. The following reading provides a dense, clear summary of these steps.
Normal distribution - Maximum likelihood estimation
This article from Statlect presents the formal derivation in a clear, step-by-step format. It's a great way to review the mathematics from the video.
Start by reviewing the Assumptions and the probability density function for a normal variable. Next, see how this is used to construct the likelihood function for an IID sample. Then, follow the transformation to the log-likelihood function. Finally, read the core of the derivation in the section The maximum likelihood estimators, where the partial derivatives are taken and the system is solved.
To summarize the key results from the derivation, given a dataset of samples :
-
Log-Likelihood Function:
The log-likelihood function for a Gaussian distribution simplifies to: -
MLE for the Mean ():
By taking the partial derivative , setting it to zero, and solving, we find:This is simply the sample mean of the data.
-
MLE for the Variance ():
By taking the partial derivative , setting it to zero, and solving, we get:This is the sample variance of the data, calculated using the MLE estimate for the mean, .
These results are powerful because they are so intuitive. The "most likely" Gaussian distribution to have generated your data is the one centered at your data's average, with a variance that matches your data's average squared distance from that center. MLE gives us a formal, rigorous proof for using these familiar estimators.
It's worth noting a subtle but important point for your future studies. The MLE for variance, , is known as a biased estimator. In many statistical packages, you'll find that the sample variance is calculated with a denominator of instead of . That version is an unbiased estimator. While they are numerically very similar for large datasets, this distinction is theoretically important and something we may revisit later.
Conclusion
In this lesson, you have walked through the complete mathematical derivation of the Maximum Likelihood Estimators for the parameters of a Gaussian distribution. You saw how a standard, multi-step process involving the log-likelihood function and partial derivatives leads to the intuitive result that the sample mean and sample variance are the MLEs for and . This process serves as a template for deriving estimators for many other probabilistic models in machine learning.
In our next lesson, we will build directly on this foundation. We will move to Maximum A Posteriori (MAP) estimation, applying it to a linear regression problem. This will bring us back to the Bayesian perspective by incorporating a prior, and you will see a fascinating connection between MAP and the regularization techniques you are already familiar with.