Discrete Random Variables
View .md

Functions of Random Variables

The Expected Value Rule

If g(X)g(X) is a function of random variable XX:

E[g(X)]=∑xg(x)⋅pX(x)E[g(X)] = \sum_x g(x) \cdot p_X(x)

This formula lets you find the expected value of g(X)g(X) without first finding the PMF of g(X)g(X).


Key Insight: Cannot Interchange Expectation and Functions

In general:

E[g(X)]≠g(E[X])E[g(X)] \neq g(E[X])

You cannot reason on averages when dealing with non-linear functions.

Example: Reciprocal

If XX is a random variable, then:

E[1X]≠1E[X]E\left[\frac{1}{X}\right] \neq \frac{1}{E[X]}

From the travel example: E[T]=E[200/V]=100.5E[T] = E[200/V] = 100.5, but 200/E[V]=200/100.5≈2200/E[V] = 200/100.5 \approx 2.

These are completely different!


Exceptions: Linear Functions

For linear functions g(X)=aX+bg(X) = aX + b:

E[aX+b]=aE[X]+bE[aX + b] = aE[X] + b

This is the linearity of expectation. It always works, even for dependent random variables.

Temperature Conversion

If XX is temperature in Celsius and Y=1.8X+32Y = 1.8X + 32 is temperature in Fahrenheit:

E[Y]=1.8E[X]+32E[Y] = 1.8E[X] + 32

You can first convert to Fahrenheit, then average. Or average in Celsius, then convert. Either way gives the same result.


Multiple Random Variables

For multiple random variables, linearity still holds:

E[X+Y+Z]=E[X]+E[Y]+E[Z]E[X + Y + Z] = E[X] + E[Y] + E[Z]

SAT Example

If X,Y,ZX, Y, Z are scores on three SAT sections:

  • Total score =X+Y+Z= X + Y + Z
  • Average total =E[X]+E[Y]+E[Z]= E[X] + E[Y] + E[Z]

You can average each section separately, then add. Or add scores for each student, then average. Same result.


Product of Independent Random Variables

If XX and YY are independent:

E[XY]=E[X]⋅E[Y]E[XY] = E[X] \cdot E[Y]

Why Does This Work?

If XX and YY are independent, knowing XX tells you nothing about YY. Therefore, knowing XX tells you nothing about g(Y)g(Y) for any function gg.

So if XX and YY are independent, then g(X)g(X) and h(Y)h(Y) are also independent, and:

E[g(X)h(Y)]=E[g(X)]⋅E[h(Y)]E[g(X)h(Y)] = E[g(X)] \cdot E[h(Y)]


Variance of Functions

Scaling

Var(aX)=a2Var(X)\text{Var}(aX) = a^2 \text{Var}(X)

The variance scales by the square of the scaling factor.

Shifting

Var(X+b)=Var(X)\text{Var}(X + b) = \text{Var}(X)

Adding a constant shifts the distribution but doesn’t change its spread.

Sum of Independent RVs

If XX and YY are independent:

Var(X+Y)=Var(X)+Var(Y)\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y)

Warning: This fails for dependent variables!

Example: Dependent Variables

If X=YX = Y, then:

  • Var(X+Y)=Var(2X)=4Var(X)\text{Var}(X + Y) = \text{Var}(2X) = 4\text{Var}(X)
  • But Var(X)+Var(Y)=2Var(X)\text{Var}(X) + \text{Var}(Y) = 2\text{Var}(X)

These are different!


Indicator Variables

An indicator variable takes values 0 or 1, indicating whether an event occurred.

Binomial Example

For nn coin flips with probability pp of heads:

Let Xi=1X_i = 1 if flip ii is heads, 0 otherwise.

Then X=X1+X2+⋯+XnX = X_1 + X_2 + \cdots + X_n counts total heads.

E[X]=E[X1]+E[X2]+⋯+E[Xn]=npE[X] = E[X_1] + E[X_2] + \cdots + E[X_n] = np

This is much easier than summing over the binomial PMF!


Key Terms

Expected Value RuleE[g(X)]=∑g(x)⋅P(X=x)E[g(X)] = \sum g(x) \cdot P(X=x) for discrete, or ∫g(x)⋅f(x) dx\int g(x) \cdot f(x) \, dx for continuous random variables.
LinearityE[X + Y] = E[X] + E[Y] and E[cX] = cE[X] — holds regardless of dependence.
Independent ProductsIf X and Y are independent, then E[XY] = E[X]·E[Y] and Var(X+Y) = Var(X) + Var(Y).
Indicator VariableA Bernoulli variable that is 1 if an event AA occurs and 0 otherwise; E[IA]=P(A)E[I_A] = P(A).