Course contentsShow
← Data Science
Lesson 159 of 2,1455. Continuous Probability DistributionsFree lesson

Expected Value and Variance for Continuous Variables

Learn formulas for expectation and variance using integrals instead of sums.

Expected Value and Variance for Continuous Variables

What you'll learn: How to calculate the mean and spread of continuous random variables using integrals instead of sums.

From Sums to Integrals

Remember calculating expected value for discrete variables? You multiplied each value by its probability and summed them up. For continuous variables, we do something similar—but since there are infinitely many values, we replace the sum with an integral.

Think of it like this: instead of adding up distinct chunks, you're smoothly accumulating tiny contributions across the entire range of possible values.

Expected Value Formula

For a continuous random variable X with probability density function f(x):

E[X] = ∫ x · f(x) dx

You integrate over all possible values. This weighted average tells you the "center of mass" of the distribution—where values tend to cluster on average.

Variance Formula

Variance measures spread around the mean. For continuous variables:

Var(X) = ∫ (x - μ)² · f(x) dx

Or equivalently:

Var(X) = E[X²] - (E[X])²

where E[X²] = ∫ x² · f(x) dx

The second formula is often easier to compute: find the expected value of the squared variable, then subtract the square of the expected value.

Why This Matters

These integrals give you the same information expectation and variance gave you for discrete variables—central tendency and variability—but now for variables that can take on any value in a range (like height, time, or temperature). The PDF acts like weights, telling you which regions contribute more to the average.

Key Takeaway: For continuous random variables, replace probability sums with integrals over the PDF to find expected value (E[X] = ∫ x·f(x) dx) and variance (Var(X) = E[X²] - (E[X])²).