Skip to main content

Someone wanted to learn this too, so Grasp built them a personal learning path.

You can keep exploring this one or create your own

Moments of the Gaussian Distribution

Hello! Welcome to your next lesson on the mathematical foundations of AI.

In our last session, we formally derived the mean and variance for two fundamental discrete distributions, the Bernoulli and Binomial. We saw how algebraic manipulation and understanding the relationships between distributions were key to these proofs.

Today, we shift our focus from the discrete to the continuous realm to study the single most important probability distribution in statistics and machine learning: the Gaussian (or Normal) distribution. Your learning outcome is to derive the mean and variance of the univariate Gaussian distribution from its Probability Density Function (PDF). This will require us to apply the definitions of expectation and variance in a continuous setting, leveraging your calculus skills for integration over infinite domains.

Given your goal of achieving a deep theoretical understanding, we will follow the standard, rigorous approach: first, we will prove the properties for the simpler standard normal distribution, and then we will generalize our findings.

1. The Gaussian Distribution and the Standardization Strategy

The Probability Density Function (PDF) for a general univariate Gaussian random variable with parameters and , denoted , is given by:

As the notation suggests, our goal is to prove that the parameter is the mean and is the variance.

Attempting to derive these directly from this general formula involves some heavy algebra. A more elegant and standard approach in mathematics is to first analyze the simplest case: the standard normal distribution, , where and . Its PDF is:

We will prove that for , the mean is indeed 0 and the variance is 1. Then, we will show how any normal variable can be seen as a simple transformation of , which will allow us to find the mean and variance of effortlessly.

2. The Normalizing Constant and the Polar Coordinates Trick

Before we can compute the mean or variance, we must first trust that is a valid PDF. This means its integral over the entire real line must be 1.

This is equivalent to showing that the integral of is . This integral, known as the Gaussian integral, has no elementary antiderivative. Its solution is a classic and beautiful proof that you should know.

The following video from a Harvard Statistics course provides a rigorous derivation of this normalizing constant.

Lecture 13: Normal distribution | Statistics 110

This segment of 'Lecture 13: Normal distribution' from Harvard University details the famous trick for solving the Gaussian integral by squaring it and converting to polar coordinates. This is a cornerstone proof in this area.

Watch the segment from 29:11 to 40:42. Pay close attention to the setup: squaring the integral, combining it into a double integral, and the change of variables from Cartesian (x, y) to polar (r, θ), including the Jacobian 'r'.

This proof is a fantastic example of a non-obvious mathematical strategy solving a seemingly intractable problem. The appearance of from this integration is what connects the Gaussian distribution to circles, a surprising and deep result.

3. Deriving the Mean and Variance of the Standard Normal Distribution

Now that we have confidence in the PDF, let's derive its mean and variance. The following resource provides a clear walkthrough of both derivations.

Lecture 13: Normal distribution | Statistics 110

Continuing with the Harvard lecture, this next part uses the now-verified PDF to derive the mean and variance of the standard normal distribution.

Watch the segment from 40:42 to 49:05. For the mean (E[Z]): Note the elegant use of symmetry. The integrand is an 'odd function', and the integral of any odd function over a symmetric domain like (-∞, ∞) is zero. For the variance (Var(Z)): Follow the calculation of E[Z²] using integration by parts. Pay attention to how the integral is cleverly set up to make the derivation work.

Let's summarize the steps from the video, as they are crucial.

Mean of

By definition, the expected value is:

The integrand, let's call it , is an odd function because . The integral of any odd function over a symmetric interval [-a, a] is always zero, as the negative area cancels the positive area. Therefore:

Variance of

We use the formula . Since , this simplifies to .

This is solved using integration by parts, . The key is the choice of and :

  • Let , so .
  • Let . We can integrate this to get .

Substituting into the formula:

Evaluating this over :

The first term goes to zero because the exponential term decays much faster than grows. The second term is the Gaussian integral we evaluated earlier, which equals .

Putting it all together for the variance:

For a concise, written version of these proofs, the following resource is excellent.

Normal Distribution | Gaussian | Normal random variables

The website 'probabilitycourse.com' provides clear, textbook-style derivations. This is a great text-based companion to the video lecture you just watched.

Read the section that begins just after Figure 4.6 and ends just before 'CDF of the standard normal'. This section, 'Let us find the mean and variance of the standard normal distribution', concisely covers the exact same proofs for E[Z]=0 and E[Z^2]=1.

Test your understanding!

Why can't we use the same integration by parts strategy to solve for ? What happens if you try to set and ?

Show answer

If you try to use integration by parts for , you could set and . However, you cannot find a simple antiderivative for , as this is the core problem of the Gaussian integral.

Alternatively, if you set and , then and . The formula would give you:

This makes the integral more complex, not simpler. The odd-function symmetry argument is far more direct and powerful for finding the mean.

4. Generalizing to an Arbitrary Gaussian Distribution

We have now rigorously proven that for , and . The final step is to generalize this to .

Any general normal random variable can be expressed as a linear transformation of a standard normal variable :

Using the properties of expectation and variance that we have already established, the proofs become trivial.

Normal Distribution | Gaussian | Normal random variables

The same article from probabilitycourse.com explains this generalization clearly.

Read the section titled 'Normal random variables'. Focus on the derivations for EX and Var(X) using the relationship X = σZ + μ. Also, notice how the PDF for the general normal is derived from the standard normal PDF using the chain rule.

As shown in the resource, the derivation is beautifully simple:

Mean of
Using the linearity of expectation:

Variance of
Using the properties of variance:

And with that, we have proven that the parameters and in the Gaussian PDF are indeed its mean and variance. This standardization approach () is a fundamental technique used throughout statistics.

Conclusion

In this lesson, you have performed one of the most classic derivations in probability theory, solidifying your understanding of both the Gaussian distribution and advanced calculus techniques.

Key Takeaways:

  • The mean and variance of a general Gaussian distribution are and , respectively.
  • The rigorous proof follows a standard strategy:
    1. Prove the properties for the standard normal first.
    2. Generalize to using the linear transformation .
  • Key mathematical tools used were:
    • The Gaussian integral (solved with polar coordinates) to find the normalizing constant .
    • The property of odd functions integrating to zero to find the mean.
    • Integration by parts to find the variance.

Preview of the Next Lesson:
So far, we have focused on single random variables. However, most real-world AI problems, from image recognition to natural language processing, involve relationships between many variables. In the next lesson, we will begin our exploration of the multivariate world by defining joint, marginal, and conditional distributions for multiple random variables.

Can't find a good explanation? Sign up and we'll make it for you

Sign up