Expectation and Variance
Swipe um das Menü anzuzeigen
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 61 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)
Danke für Ihr Feedback!
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen