Expectation and Variance
Swipe to show menu
Formulas for Expectation and Variance
The expected value (or expectation) of a discrete random variable $X$ is the long-run average value of repetitions of the experiment it represents. The formula is:
E[X]=iββxiββ P(X=xiβ)where xiβ are the possible outcomes, and P(X=xiβ) is the probability of each outcome.
The variance of a random variable X measures how much the values of X are spread out around the expected value. The formula is:
Var(X)=E[(XβE[X])2]=iββ(xiββE[X])2β P(X=xiβ)Step-by-Step Calculation Example
Suppose you have a random variable X representing the outcome of rolling a fair six-sided die, so X can be 1, 2, 3, 4, 5, or 6, each with probability 1/6.
-
Calculate the expectation:
E[X]=1Γ61β+2Γ61β+3Γ61β+4Γ61β+5Γ61β+6Γ61β=3.5 -
Calculate the variance:
- First, compute (xiββE[X])2 for each outcome:
- For x1β=1: (1β3.5)2=6.25;
- For x2β=2: (2β3.5)2=2.25;
- For x3β=3: (3β3.5)2=0.25;
- For x4β=4: (4β3.5)2=0.25;
- For x5β=5: (5β3.5)2=2.25;
- For x6β=6: (6β3.5)2=6.25.
- Multiply each by 6β1β and sum: Var(X)=61β(6.25+2.25+0.25+0.25+2.25+6.25)=617.5ββ2.92
- First, compute (xiββE[X])2 for each outcome:
12345678910111213# Compute expectation and variance for a discrete random variable in Python outcomes = [1, 2, 3, 4, 5, 6] # Possible outcomes of a fair die probabilities = [1/6] * 6 # Each outcome has equal probability # Calculate expectation (mean) expectation = sum(x * p for x, p in zip(outcomes, probabilities)) # Calculate variance variance = sum(((x - expectation) ** 2) * p for x, p in zip(outcomes, probabilities)) print("Expectation (mean):", expectation) print("Variance:", variance)
Everything was clear?
Thanks for your feedback!
SectionΒ 1. ChapterΒ 9
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
SectionΒ 1. ChapterΒ 9