10  Operations on random variables

11 Operations on random variables

Let’s learn how to combine random variables (add, subtract, multiply). How do these operations affect the expected value and variance?

NoteMotivating example: Karan Johar films vs Rajkumar Hirani films

Two of the most important Indian filmmakers are Karan Johar and Rajkumar Hirani. Karan Johar makes romantic dramas like Dilwale Dulhania Le Jayenge, Kal Ho Naa Ho, Kabhi Khushi Kabhie Gham, and My Name Is Khan with runtimes averaging 150+ minutes. Rajkumar Hirani makes comedies like the Munna Bhai series, 3 Idiots, and PK that run closer to 140 minutes.

A theatre chain faces a practical question: If they add a 10-minute intermission to all Karan Johar films, what’s the expected new runtime? If they screen one Karan Johar film and one Rajkumar Hirani film back-to-back, what’s the combined runtime? Are IMDb ratings and runtimes correlated across their films? To answer these questions, we’ll have to combine random variables.

11.1 Shifting and scaling random variables

When we change a random variable by adding or multiplying it, its centre and spread change.

11.1.1 Adding or subtracting a constant

If \(X\) is a random variable and \(c\) is a constant:

\[E(X + c) = E(X) + c\] \[\text{Var}(X + c) = \text{Var}(X)\]

Adding a constant shifts the distribution but doesn’t change the spread. If all Karan Johar films get a 10-minute intermission, the expected runtime grows by 10 minutes while variability stays the same.

11.1.2 Multiplying by a constant

If \(a\) is a constant:

\[E(aX) = a \cdot E(X)\] \[\text{Var}(aX) = a^2 \cdot \text{Var}(X)\]

Multiplying scales both the mean and variance, but variance scales by the square of the multiplier. If a cinema doubles all runtimes (say, for a re-release with bonus content), the expected runtime doubles, but the variance quadruples. Unpredictability grows faster than the multiplier itself.

Karan Johar films runtime distribution:
  E(X) = 182.5 minutes
  Var(X) = 18.8
  SD(X) = 4.33 minutes

After adding 10-minute intermission:
  E(X + 10) = 192.5 minutes
  Var(X + 10) = 18.8 (unchanged)

If runtime is doubled (for director's extended cut):
  E(2X) = 365.0 minutes
  Var(2X) = 75.0
  SD(2X) = 8.66 minutes

11.2 Adding two independent random variables

When two films release on the same day and screen in different theaters, the total runtime across both screens depends on both runtimes.

For two arbitrary random variables \(X\) and \(Y\):

\[E(X + Y) = E(X) + E(Y)\]

For two independent random variables \(X\) and \(Y\):

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

When you add two independent sources of uncertainty, the variances are summed.X

NoteExample: Two directors’ films releasing simultaneously

Suppose a Karan Johar film has \(E(X) = 180\) minutes and \(\text{Var}(X) = 50\), while a Rajkumar Hirani film has \(E(Y) = 140\) minutes and \(\text{Var}(Y) = 40\).

The expected total runtime is \(E(X + Y) = 180 + 140 = 320\) minutes. The variance of total runtime is \(\text{Var}(X + Y) = 50 + 40 = 90\), giving \(\text{SD}(X + Y) = \sqrt{90} \approx 9.5\) minutes.

11.3 Differences of random variables

When comparing two filmmakers’ typical runtimes, we ask how much longer one runs than the other. This is a difference of random variables. For \(D = X - Y\):

\[E(X - Y) = E(X) - E(Y)\] \[\text{Var}(X - Y) = \text{Var}(X) + \text{Var}(Y) \quad \text{(if independent)}\]

Notice that the variance of a difference equals the variance of a sum. Both add variances, meaning that uncertainty grows the same way.

NoteExample: Runtime gap between directors

The expected difference is \(E(X - Y) = 180 - 140 = 40\) minutes. Variance of difference is \(\text{Var}(X - Y) = 50 + 40 = 90\), the same as the sum. Standard deviation is \(\text{SD}(X - Y) = \sqrt{90} \approx 9.5\) minutes.

Karan Johar films typically run about 40 minutes longer than Rajkumar Hirani films, with a variability of ±9.5 minutes around that gap.

TipWhy insurance pools reduce risk

An insurer offering $100M payout per film with 1% loss probability has:

  • $E() = $$1M
  • $ = $$9.95M

But across 100 independent films: - $E() = $$1M - $ = $$0.995M

This is the Law of Large Numbers: with enough independent policies, the average payout converges to the expected value.

11.4 Summing many instances of the same random variable

A studio releases a trilogy. All films have the same distribution of runtimes. What’s the expected total runtime across all three?

\[T = X_1 + X_2 + X_3\]

TipA common pitfall

Write \(X_1 + X_2 + X_3\), not \(X + X + X\). When you say “three independent sampling of the same random variable,” you mean three independent instances, each with the same distribution. Each instance is a separate random outcome. Writing \(T = 3X\) means something different: multiply the first instance by 3.

If \(X_1, X_2, \ldots, X_n\) are independent, identically distributed (iid) random variables:

\[E(X_1 + X_2 + \cdots + X_n) = n \cdot E(X)\] \[\text{Var}(X_1 + X_2 + \cdots + X_n) = n \cdot \text{Var}(X)\]

Multiply a single random variable by \(n\) instead, and the variances differ:

\[E(nX) = n \cdot E(X)\] \[\text{Var}(nX) = n^2 \cdot \text{Var}(X)\]

Variance scales by \(n^2\), not \(n\). This is the difference between “one film with \(n\) times the runtime” (highly variable) and “\(n\) films each with normal runtime” (less variable because they’re independent).

NoteExample: Three Karan Johar films on a marathon day

Each film has an expected runtime of 180 minutes and a variance of 50. For the marathon total \(T = X_1 + X_2 + X_3\):

\[E(T) = 3 \times 180 = 540 \text{ minutes (9 hours)}\] \[\text{Var}(T) = 3 \times 50 = 150\] \[\text{SD}(T) = \sqrt{150} \approx 12.2 \text{ minutes}\]

A single “director’s cut” that’s 3× runtime (\(Y = 3X_1\)) would have the same expected value but higher variance:

\[E(Y) = 3 \times 180 = 540 \text{ minutes}\] \[\text{Var}(Y) = 9 \times 50 = 450\] \[\text{SD}(Y) = \sqrt{450} \approx 21.2 \text{ minutes}\]

Three independent films have less variability than one 540-minute extended cut.

11.5 Covariance and correlation

So far, we’ve assumed random variables are independent. But many pairs of random variables move together, e.g., box office revenues and IMDb ratings, or runtime and viewer ratings.

11.5.1 Covariance

Covariance measures how two random variables vary together:

\[\text{Cov}(X, Y) = E[(X - \mu_X)(Y - \mu_Y)]\]

where \(\mu_X = E(X)\) and \(\mu_Y = E(Y)\).

If \(X\) and \(Y\) tend to be above their means together, or below together, covariance is positive. If one goes up while the other goes down, covariance is negative. Independent variables have zero covariance.

11.5.2 Correlation

Covariance is hard to interpret because its size depends on the units of \(X\) and \(Y\). Correlation standardises it:

\[\rho = \text{Corr}(X, Y) = \frac{\text{Cov}(X, Y)}{\sigma_X \sigma_Y}\]

Correlation always falls between \(-1\) and \(+1\). A value of 1 means a perfect positive relationship, 0 means no linear relationship, and \(-1\) means a perfect negative relationship.

11.5.3 Variance of sums when variables are dependent

If \(X\) and \(Y\) are not independent, the variance rule changes:

\[\text{Var}(X + Y) = \text{Var}(X) + \text{Var}(Y) + 2 \times \text{Cov}(X, Y)\]

Positive covariance increases total variance. Negative covariance decreases it. In portfolio management, you would combine assets with negative correlation to reduce portfolio risk.

11.6 Summary: Rules for operations on random variables

Operation Expected Value Variance
\(X + c\) (shift) \(E(X) + c\) \(\text{Var}(X)\)
\(aX\) (scale) \(a \cdot E(X)\) \(a^2 \cdot \text{Var}(X)\)
\(X + Y\) (independent) \(E(X) + E(Y)\) \(\text{Var}(X) + \text{Var}(Y)\)
\(X - Y\) (independent) \(E(X) - E(Y)\) \(\text{Var}(X) + \text{Var}(Y)\)
\(X + Y\) (dependent) \(E(X) + E(Y)\) \(\text{Var}(X) + \text{Var}(Y) + 2\text{Cov}(X,Y)\)
\(X_1 + \cdots + X_n\) (iid) \(n \cdot E(X)\) \(n \cdot \text{Var}(X)\)