Lesson 9 of 15
Expectation & Variance Properties
Rules for Transforming Random Variables
Linearity of Expectation
For any constants and :
This holds for all random variables, regardless of dependence or distribution. It is the most useful fact in probability.
Variance Under Linear Transformation
Adding a constant shifts the distribution but does not change spread. Scaling by stretches spread by , so variance scales by .
# X ~ Bernoulli(0.5): E[X] = 0.5, Var(X) = 0.25
# Y = 2X + 3
# E[Y] = 2*0.5 + 3 = 4.0
# Var(Y) = 4 * 0.25 = 1.0
mean_x, var_x = 0.5, 0.25
a, b = 2, 3
print(round(a * mean_x + b, 4)) # 4.0
print(round(a**2 * var_x, 4)) # 1.0
Sum of Independent Random Variables
Your Task
Implement linear_transform(mean_x, var_x, a, b) that prints and , each rounded to 4 decimal places.
Pyodide loading...
Loading...
Click "Run" to execute your code.