Practice / Probability for ML

Discrete random variables: expectation, variance and the binomial, geometric and Poisson

Ten problems on discrete random variables: expectation and variance from a probability table, a fair die and Var(aX + b), the binomial probabilities and its mean and variance from indicators, linearity of expectation without independence in the matching problem, the geometric distribution and memorylessness, Poisson counts and the Poisson limit of the binomial, the laws of total expectation and variance, and the expected number of distinct examples in a bootstrap sample, with worked solutions and the mistakes of squaring the mean, dropping the binomial coefficient and adding probabilities that overlap.

Before you start

A discrete random variable is a number that comes out of a random experiment: the count of correct predictions in a batch, the number of retries before a request succeeds, the number of events in a minute. Its distribution is a list of values and their probabilities, and almost everything asked about it is a weighted sum over that list. Two facts do most of the work. Expectation is linear, E[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y], whether or not XX and YY are independent, which turns hard counts into sums of easy indicators. Variance is not linear, and the place it goes wrong is the place the squares are. These ten problems build the binomial, geometric and Poisson distributions from first principles, and end with the expected number of distinct examples in a bootstrap sample, the 63.2%63.2\% behind bagging's out-of-bag estimate.

  • A discrete random variable XX has a probability mass function p(x)=P(X=x)p(x) = P(X = x) with p(x)≥0p(x) \ge 0 and ∑xp(x)=1\sum_x p(x) = 1.
  • Expectation. E[X]=∑xx p(x)E[X] = \sum_x x\,p(x), and for any function gg, E[g(X)]=∑xg(x) p(x)E[g(X)] = \sum_x g(x)\,p(x). In general E[g(X)]≠g(E[X])E[g(X)] \ne g(E[X]); in particular E[X2]≠(E[X])2E[X^2] \ne (E[X])^2.
  • Linearity. E[aX+b]=aE[X]+bE[aX + b] = aE[X] + b, and E[X+Y]=E[X]+E[Y]E[X + Y] = E[X] + E[Y] for any XX and YY, independent or not.
  • Variance. Var⁡(X)=E[(X−E[X])2]=E[X2]−(E[X])2\operatorname{Var}(X) = E[(X - E[X])^2] = E[X^2] - (E[X])^2, and the standard deviation is its square root. Var⁡(aX+b)=a2Var⁡(X)\operatorname{Var}(aX + b) = a^2\operatorname{Var}(X). For independent XX and YY, Var⁡(X+Y)=Var⁡X+Var⁡Y\operatorname{Var}(X + Y) = \operatorname{Var}X + \operatorname{Var}Y; otherwise add 2Cov⁡(X,Y)2\operatorname{Cov}(X, Y).
  • Indicators. For an event AA, IA=1I_A = 1 if AA happens and 00 otherwise. E[IA]=P(A)E[I_A] = P(A) and IA2=IAI_A^2 = I_A.
  • Binomial(n,p)(n, p): the number of successes in nn independent trials with success probability pp. P(X=k)=(nk)pk(1−p)n−kP(X = k) = \binom nk p^k(1 - p)^{n - k} for k=0,…,nk = 0, \dots, n, where (nk)=n!k! (n−k)!\binom nk = \frac{n!}{k!\,(n - k)!} counts the orders in which the kk successes can occur.
  • Geometric(p)(p): the number of the trial on which the first success happens, P(X=k)=(1−p)k−1pP(X = k) = (1 - p)^{k - 1}p for k=1,2,…k = 1, 2, \dots Some books count the failures before it instead, which shifts everything by 11.
  • Poisson(λ)(\lambda): P(X=k)=e−λλk/k!P(X = k) = e^{-\lambda}\lambda^k/k! for k=0,1,2,…k = 0, 1, 2, \dots, a count of events that occur independently at an average rate λ\lambda per interval. The series ∑k≥0λk/k!=eλ\sum_{k \ge 0}\lambda^k/k! = e^\lambda makes the probabilities sum to 11.
  • Conditioning. E[X]=E[E[X∣Y]]E[X] = E\big[E[X \mid Y]\big] and Var⁡(X)=E[Var⁡(X∣Y)]+Var⁡(E[X∣Y])\operatorname{Var}(X) = E\big[\operatorname{Var}(X \mid Y)\big] + \operatorname{Var}\big(E[X \mid Y]\big).

Problems

  1. ·

    XX takes the values 0,1,2,30, 1, 2, 3 with probabilities 0.10.1, 0.30.3, 0.40.4 and 0.20.2. Find E[X]E[X], E[X2]E[X^2], Var⁡(X)\operatorname{Var}(X) and the standard deviation.

  2. ·

    XX is the roll of a fair six-sided die. Find E[X]E[X], E[X2]E[X^2] and Var⁡(X)\operatorname{Var}(X), and then E[2X+3]E[2X + 3] and Var⁡(2X+3)\operatorname{Var}(2X + 3).

  3. ··

    A classifier labels 1010 independent examples, each correctly with probability 0.80.8. Find the probability that exactly 88 are correct, the probability that at least 99 are, and the mean and variance of the number correct.

  4. ··

    Show that a Binomial⁡(n,p)\operatorname{Binomial}(n, p) variable has mean npnp and variance np(1−p)np(1 - p) by writing it as a sum of indicators.

  5. ··

    n≥2n \ge 2 letters are put into nn addressed envelopes in a uniformly random order. Let XX be the number that land in the right envelope. Find E[X]E[X] and Var⁡(X)\operatorname{Var}(X).

  6. ··

    A request succeeds on each attempt with probability 0.20.2, independently, and is retried until it succeeds. Let XX be the number of attempts. Find E[X]E[X], P(X>3)P(X > 3), the probability of success within 33 attempts, and P(X>5∣X>2)P(X > 5 \mid X > 2).

  7. ··

    Errors arrive in a log at an average of 33 per minute, as a Poisson count. Find the probability of no errors in a minute, of at most 22, and of at least 33, and show from the series that E[X]=λE[X] = \lambda.

  8. ···

    A rare label occurs with probability 0.0020.002 per example, independently, in a batch of 10001000. Compare the exact binomial probabilities of 00 and of 33 occurrences with the Poisson approximation, and say why the approximation works.

  9. ···

    A fair die is rolled, and if it shows KK, then KK fair coins are flipped. Let XX be the number of heads. Find E[X]E[X] and Var⁡(X)\operatorname{Var}(X).

  10. ···

    A bootstrap sample draws nn examples uniformly at random, with replacement, from a training set of nn. Find the expected number of distinct examples in it, evaluate it for n=10n = 10, and find the fraction it approaches as nn grows.

Worked solutions

Problem 1

XX takes the values 0,1,2,30, 1, 2, 3 with probabilities 0.10.1, 0.30.3, 0.40.4 and 0.20.2. Find E[X]E[X], E[X2]E[X^2], Var⁡(X)\operatorname{Var}(X) and the standard deviation.

  1. 0.1+0.3+0.4+0.2=10.1 + 0.3 + 0.4 + 0.2 = 1Check the table is a distribution before using it.
  2. E[X]=0(0.1)+1(0.3)+2(0.4)+3(0.2)=1.7E[X] = 0(0.1) + 1(0.3) + 2(0.4) + 3(0.2) = 1.7Each value weighted by its probability.
  3. E[X2]=0(0.1)+1(0.3)+4(0.4)+9(0.2)=3.7E[X^2] = 0(0.1) + 1(0.3) + 4(0.4) + 9(0.2) = 3.7Square the values, not the probabilities, and keep the same weights.
  4. Var⁡(X)=3.7−1.72=3.7−2.89=0.81\operatorname{Var}(X) = 3.7 - 1.7^2 = 3.7 - 2.89 = 0.81The shortcut E[X2]−(E[X])2E[X^2] - (E[X])^2.
  5. E[X]=1.7E[X] = 1.7, E[X2]=3.7E[X^2] = 3.7, Var⁡(X)=0.81\operatorname{Var}(X) = 0.81, standard deviation 0.90.9Check from the definition: 0.1(1.7)2+0.3(0.7)2+0.4(0.3)2+0.2(1.3)2=0.289+0.147+0.036+0.338=0.810.1(1.7)^2 + 0.3(0.7)^2 + 0.4(0.3)^2 + 0.2(1.3)^2 = 0.289 + 0.147 + 0.036 + 0.338 = 0.81.

Problem 2

XX is the roll of a fair six-sided die. Find E[X]E[X], E[X2]E[X^2] and Var⁡(X)\operatorname{Var}(X), and then E[2X+3]E[2X + 3] and Var⁡(2X+3)\operatorname{Var}(2X + 3).

  1. E[X]=1+2+⋯+66=216=3.5E[X] = \dfrac{1 + 2 + \cdots + 6}{6} = \dfrac{21}{6} = 3.5Each face has probability 16\tfrac16.
  2. E[X2]=1+4+9+16+25+366=916E[X^2] = \dfrac{1 + 4 + 9 + 16 + 25 + 36}{6} = \dfrac{91}{6}The same weights on the squares.
  3. Var⁡(X)=916−494=182−14712=3512\operatorname{Var}(X) = \dfrac{91}{6} - \dfrac{49}{4} = \dfrac{182 - 147}{12} = \dfrac{35}{12}About 2.9172.917.
  4. E[2X+3]=2(3.5)+3=10E[2X + 3] = 2(3.5) + 3 = 10 and Var⁡(2X+3)=4⋅3512=353\operatorname{Var}(2X + 3) = 4\cdot\dfrac{35}{12} = \dfrac{35}{3}Shifting by 33 moves every value and the mean together, so the spread is unchanged; scaling by 22 doubles every deviation and so multiplies their squares by 44.
  5. E[X]=3.5E[X] = 3.5, E[X2]=916E[X^2] = \tfrac{91}{6}, Var⁡(X)=3512\operatorname{Var}(X) = \tfrac{35}{12}; E[2X+3]=10E[2X + 3] = 10, Var⁡(2X+3)=353≈11.67\operatorname{Var}(2X + 3) = \tfrac{35}{3} \approx 11.67Check: 2X+32X + 3 takes the values 5,7,…,155, 7, \dots, 15, and the mean of their squares minus 10210^2 is 25+49+81+121+169+2256−100=6706−100=353\tfrac{25 + 49 + 81 + 121 + 169 + 225}{6} - 100 = \tfrac{670}{6} - 100 = \tfrac{35}{3}.

Problem 3

A classifier labels 1010 independent examples, each correctly with probability 0.80.8. Find the probability that exactly 88 are correct, the probability that at least 99 are, and the mean and variance of the number correct.

  1. X∼Binomial⁡(10,0.8)X \sim \operatorname{Binomial}(10, 0.8)A fixed number of independent trials with the same success probability.
  2. P(X=8)=(108)(0.8)8(0.2)2=45⋅0.16777⋅0.04≈0.3020P(X = 8) = \dbinom{10}{8}(0.8)^8(0.2)^2 = 45 \cdot 0.16777 \cdot 0.04 \approx 0.3020(108)=(102)=45\binom{10}{8} = \binom{10}{2} = 45: the two errors can be any two of the ten examples.
  3. P(X≥9)=(109)(0.8)9(0.2)+(0.8)10≈0.2684+0.1074=0.3758P(X \ge 9) = \dbinom{10}{9}(0.8)^9(0.2) + (0.8)^{10} \approx 0.2684 + 0.1074 = 0.3758The events X=9X = 9 and X=10X = 10 are disjoint, so their probabilities add.
  4. E[X]=np=8E[X] = np = 8 and Var⁡(X)=np(1−p)=10⋅0.8⋅0.2=1.6\operatorname{Var}(X) = np(1 - p) = 10 \cdot 0.8 \cdot 0.2 = 1.6Problem 4 derives both.
  5. P(X=8)≈0.302P(X = 8) \approx 0.302, P(X≥9)≈0.376P(X \ge 9) \approx 0.376, E[X]=8E[X] = 8, Var⁡(X)=1.6\operatorname{Var}(X) = 1.6Even at the mean, 88 correct happens less than a third of the time; the standard deviation is 1.6≈1.26\sqrt{1.6} \approx 1.26 examples.

Problem 4

Show that a Binomial⁡(n,p)\operatorname{Binomial}(n, p) variable has mean npnp and variance np(1−p)np(1 - p) by writing it as a sum of indicators.

  1. X=I1+I2+⋯+InX = I_1 + I_2 + \cdots + I_n, where Ij=1I_j = 1 if trial jj succeedsCounting successes is adding a 11 for each one.
  2. E[Ij]=1⋅p+0⋅(1−p)=pE[I_j] = 1\cdot p + 0\cdot(1 - p) = p, so E[X]=npE[X] = npLinearity of expectation; no independence needed for this step.
  3. E[Ij2]=E[Ij]=pE[I_j^2] = E[I_j] = p, so Var⁡(Ij)=p−p2=p(1−p)\operatorname{Var}(I_j) = p - p^2 = p(1 - p)An indicator is 00 or 11, so it equals its square.
  4. Var⁡(X)=∑jVar⁡(Ij)=np(1−p)\operatorname{Var}(X) = \sum_j \operatorname{Var}(I_j) = np(1 - p)The trials are independent, so the covariances are 00 and the variances add. This step does use independence.
  5. E[X]=npE[X] = np, Var⁡(X)=np(1−p)\operatorname{Var}(X) = np(1 - p)The variance is largest at p=12p = \tfrac12 and is 00 at p=0p = 0 or 11, when the outcome is certain.

Problem 5

n≥2n \ge 2 letters are put into nn addressed envelopes in a uniformly random order. Let XX be the number that land in the right envelope. Find E[X]E[X] and Var⁡(X)\operatorname{Var}(X).

  1. X=I1+⋯+InX = I_1 + \cdots + I_n with Ij=1I_j = 1 if letter jj is in its own envelope, and P(Ij=1)=1nP(I_j = 1) = \tfrac1nEach letter is equally likely to be in any of the nn envelopes.
  2. E[X]=n⋅1n=1E[X] = n\cdot\tfrac1n = 1Linearity holds even though the IjI_j are dependent: if n−1n - 1 letters are right, the last one must be.
  3. E[IiIj]=P(both right)=1n⋅1n−1E[I_iI_j] = P(\text{both right}) = \dfrac1n\cdot\dfrac{1}{n - 1} for i≠ji \ne jGiven letter ii is right, letter jj has n−1n - 1 envelopes left.
  4. E[X2]=∑jE[Ij2]+∑i≠jE[IiIj]=n⋅1n+n(n−1)⋅1n(n−1)=2E[X^2] = \sum_j E[I_j^2] + \sum_{i \ne j}E[I_iI_j] = n\cdot\dfrac1n + n(n - 1)\cdot\dfrac{1}{n(n - 1)} = 2Expand the square of the sum: nn diagonal terms and n(n−1)n(n - 1) ordered pairs.
  5. E[X]=1E[X] = 1 and Var⁡(X)=2−12=1\operatorname{Var}(X) = 2 - 1^2 = 1, for every n≥2n \ge 2Each pair has Cov⁡(Ii,Ij)=1n(n−1)−1n2>0\operatorname{Cov}(I_i, I_j) = \tfrac{1}{n(n-1)} - \tfrac{1}{n^2} > 0, and the n(n−1)n(n - 1) of them add exactly the 1n\tfrac1n that the independent formula n⋅1n(1−1n)n\cdot\tfrac1n(1 - \tfrac1n) misses (Mistake 5).

Problem 6

A request succeeds on each attempt with probability 0.20.2, independently, and is retried until it succeeds. Let XX be the number of attempts. Find E[X]E[X], P(X>3)P(X > 3), the probability of success within 33 attempts, and P(X>5∣X>2)P(X > 5 \mid X > 2).

  1. P(X=k)=0.8k−1(0.2)P(X = k) = 0.8^{k - 1}(0.2), so E[X]=∑k≥1k (0.8)k−1(0.2)=0.2(1−0.8)2=5E[X] = \sum_{k \ge 1} k\,(0.8)^{k - 1}(0.2) = \dfrac{0.2}{(1 - 0.8)^2} = 5∑k≥1kqk−1=1(1−q)2\sum_{k \ge 1}kq^{k - 1} = \tfrac{1}{(1 - q)^2} is the derivative of the geometric series ∑qk=11−q\sum q^k = \tfrac{1}{1 - q}. In general E[X]=1pE[X] = \tfrac1p.
  2. P(X>3)=0.83=0.512P(X > 3) = 0.8^3 = 0.512X>3X > 3 means the first three attempts all failed.
  3. P(X≤3)=1−0.512=0.488P(X \le 3) = 1 - 0.512 = 0.488The complement: at least one success in three attempts.
  4. P(X>5∣X>2)=P(X>5)P(X>2)=0.850.82=0.83=0.512P(X > 5 \mid X > 2) = \dfrac{P(X > 5)}{P(X > 2)} = \dfrac{0.8^5}{0.8^2} = 0.8^3 = 0.512X>5X > 5 is contained in X>2X > 2, so the intersection is X>5X > 5.
  5. E[X]=5E[X] = 5, P(X>3)=0.512P(X > 3) = 0.512, P(X≤3)=0.488P(X \le 3) = 0.488, P(X>5∣X>2)=0.512P(X > 5 \mid X > 2) = 0.512Memorylessness: after two failures, the wait for success starts afresh, so the past attempts are no evidence that success is due.

Problem 7

Errors arrive in a log at an average of 33 per minute, as a Poisson count. Find the probability of no errors in a minute, of at most 22, and of at least 33, and show from the series that E[X]=λE[X] = \lambda.

  1. P(X=0)=e−3≈0.0498P(X = 0) = e^{-3} \approx 0.0498λ0/0!=1\lambda^0/0! = 1.
  2. P(X≤2)=e−3(1+3+92)=8.5e−3≈0.4232P(X \le 2) = e^{-3}\Big(1 + 3 + \dfrac{9}{2}\Big) = 8.5e^{-3} \approx 0.4232The three terms k=0,1,2k = 0, 1, 2.
  3. P(X≥3)=1−8.5e−3≈0.5768P(X \ge 3) = 1 - 8.5e^{-3} \approx 0.5768The complement, instead of an infinite sum.
  4. E[X]=∑k≥1ke−λλkk!=λe−λ∑k≥1λk−1(k−1)!=λe−λeλ=λE[X] = \sum_{k \ge 1}k\dfrac{e^{-\lambda}\lambda^k}{k!} = \lambda e^{-\lambda}\sum_{k \ge 1}\dfrac{\lambda^{k - 1}}{(k - 1)!} = \lambda e^{-\lambda}e^{\lambda} = \lambdaThe k=0k = 0 term is 00; cancel kk against k!k! and re-index with j=k−1j = k - 1.
  5. P(0)≈0.0498P(0) \approx 0.0498, P(X≤2)≈0.4232P(X \le 2) \approx 0.4232, P(X≥3)≈0.5768P(X \ge 3) \approx 0.5768, E[X]=3E[X] = 3The same trick on E[X(X−1)]=λ2E[X(X - 1)] = \lambda^2 gives Var⁡(X)=λ2+λ−λ2=λ\operatorname{Var}(X) = \lambda^2 + \lambda - \lambda^2 = \lambda: for a Poisson count, mean and variance are equal.

Problem 8

A rare label occurs with probability 0.0020.002 per example, independently, in a batch of 10001000. Compare the exact binomial probabilities of 00 and of 33 occurrences with the Poisson approximation, and say why the approximation works.

  1. P(X=0)=0.9981000≈0.13506P(X = 0) = 0.998^{1000} \approx 0.13506Binomial with n=1000n = 1000, p=0.002p = 0.002.
  2. Poisson with λ=np=2\lambda = np = 2: P(0)=e−2≈0.13534P(0) = e^{-2} \approx 0.13534Same mean.
  3. P(X=3)=(10003)(0.002)3(0.998)997≈0.18063P(X = 3) = \dbinom{1000}{3}(0.002)^3(0.998)^{997} \approx 0.18063(10003)=166,167,000\binom{1000}{3} = 166{,}167{,}000.
  4. Poisson: e−2233!=43e−2≈0.18045\dfrac{e^{-2}2^3}{3!} = \dfrac43e^{-2} \approx 0.18045Agreement to about 0.1%0.1\%.
  5. Exact 0.135060.13506 and 0.180630.18063; Poisson 0.135340.13534 and 0.180450.18045With p=λ/np = \lambda/n, (1−λn)n→e−λ(1 - \tfrac\lambda n)^n \to e^{-\lambda} and (nk)pk→λkk!\binom nk p^k \to \tfrac{\lambda^k}{k!} as n→∞n \to \infty with λ\lambda fixed: many trials, each rarely a success, give a Poisson count.

Problem 9

A fair die is rolled, and if it shows KK, then KK fair coins are flipped. Let XX be the number of heads. Find E[X]E[X] and Var⁡(X)\operatorname{Var}(X).

  1. Given K=kK = k, X∼Binomial⁡(k,12)X \sim \operatorname{Binomial}(k, \tfrac12), so E[X∣K]=K2E[X \mid K] = \tfrac K2 and Var⁡(X∣K)=K4\operatorname{Var}(X \mid K) = \tfrac K4Problem 4 with p=12p = \tfrac12.
  2. E[X]=E[K2]=3.52=1.75E[X] = E\big[\tfrac K2\big] = \tfrac{3.5}{2} = 1.75The law of total expectation, with E[K]=3.5E[K] = 3.5 from Problem 2.
  3. E[Var⁡(X∣K)]=3.54=78E\big[\operatorname{Var}(X \mid K)\big] = \tfrac{3.5}{4} = \tfrac{7}{8}The average spread within each value of KK.
  4. Var⁡(E[X∣K])=Var⁡(K2)=14⋅3512=3548\operatorname{Var}\big(E[X \mid K]\big) = \operatorname{Var}\big(\tfrac K2\big) = \tfrac14\cdot\tfrac{35}{12} = \tfrac{35}{48}The spread of the conditional means, using Var⁡(K)=3512\operatorname{Var}(K) = \tfrac{35}{12}.
  5. E[X]=1.75E[X] = 1.75 and Var⁡(X)=78+3548=7748≈1.604\operatorname{Var}(X) = \tfrac78 + \tfrac{35}{48} = \tfrac{77}{48} \approx 1.604Using only the first term, 78\tfrac78, would ignore the uncertainty in how many coins are flipped.

Problem 10

A bootstrap sample draws nn examples uniformly at random, with replacement, from a training set of nn. Find the expected number of distinct examples in it, evaluate it for n=10n = 10, and find the fraction it approaches as nn grows.

  1. D=∑j=1nIjD = \sum_{j=1}^n I_j with Ij=1I_j = 1 if example jj is drawn at least onceCount distinct examples one example at a time.
  2. P(Ij=0)=(1−1n)nP(I_j = 0) = \big(1 - \tfrac1n\big)^nEach of the nn independent draws misses example jj with probability 1−1n1 - \tfrac1n.
  3. E[D]=n(1−(1−1n)n)E[D] = n\Big(1 - \big(1 - \tfrac1n\big)^n\Big)Linearity; the IjI_j are dependent, which does not matter for the mean.
  4. n=10n = 10: E[D]=10(1−0.910)≈10(1−0.3487)=6.513E[D] = 10(1 - 0.9^{10}) \approx 10(1 - 0.3487) = 6.513About 6.56.5 distinct examples out of 1010 draws.
  5. E[D]=n(1−(1−1n)n)E[D] = n\big(1 - (1 - \tfrac1n)^n\big); 6.5136.513 for n=10n = 10; the fraction tends to 1−e−1≈0.6321 - e^{-1} \approx 0.632(1−1n)n→e−1(1 - \tfrac1n)^n \to e^{-1}. So each bootstrap sample leaves out about 36.8%36.8\% of the training set, which bagging uses as a free validation set: the out-of-bag examples.

Where this goes wrong

1. E[X²] taken as (E[X])²

The expectation of a function is computed by putting the mean into the function.

  1. E[X]=1.7E[X] = 1.7 for the table of Problem 1Right so far.
  2. “E[X2]E[X^2] is the square of the mean.”The step that causes the mistake: expectation does not pass through a square.
  3. E[X2]=1.72=2.89E[X^2] = 1.7^2 = 2.89, so Var⁡(X)=2.89−2.89=0\operatorname{Var}(X) = 2.89 - 2.89 = 0A variance of 00 would mean XX is always 1.71.7, which it never is. E[X2]=∑x2p(x)=3.7E[X^2] = \sum x^2p(x) = 3.7, and Var⁡(X)=0.81\operatorname{Var}(X) = 0.81. The gap between E[X2]E[X^2] and (E[X])2(E[X])^2 is exactly the variance, so it is never negative.

2. Var(2X + 3) taken as 2 Var(X)

E[2X+3]=2E[X]+3E[2X + 3] = 2E[X] + 3 is linear, and the variance is expected to behave the same way.

  1. Var⁡(X)=3512\operatorname{Var}(X) = \tfrac{35}{12} for a fair dieRight so far: Problem 2.
  2. “Scaling by 22 doubles the variance, and the +3+3 drops out.”The +3+3 does drop out; the factor is what goes wrong.
  3. Var⁡(2X+3)=2⋅3512=356≈5.83\operatorname{Var}(2X + 3) = 2\cdot\tfrac{35}{12} = \tfrac{35}{6} \approx 5.83Variance is in squared units: doubling every deviation from the mean multiplies every squared deviation by 44. Var⁡(2X+3)=353≈11.67\operatorname{Var}(2X + 3) = \tfrac{35}{3} \approx 11.67, and the standard deviation, not the variance, doubles.

3. Binomial probability without the coefficient

The probability of one particular sequence of results is written down, and it looks like the answer.

  1. 1010 independent examples, each correct with probability 0.80.8Right so far: Problem 3.
  2. “Eight correct and two wrong has probability 0.88⋅0.220.8^8\cdot0.2^2.”True for one specified pattern, such as the first eight right and the last two wrong.
  3. P(X=8)=0.88(0.2)2≈0.00671P(X = 8) = 0.8^8(0.2)^2 \approx 0.00671There are (108)=45\binom{10}{8} = 45 patterns with exactly eight correct, each with that probability, so P(X=8)=45×0.00671≈0.302P(X = 8) = 45 \times 0.00671 \approx 0.302. Without the coefficient, the eleven probabilities P(X=0),…,P(X=10)P(X = 0), \dots, P(X = 10) would not sum to 11.

4. Adding probabilities that overlap

Three tries at a 20%20\% chance sounds like a 60%60\% chance.

  1. Each attempt succeeds with probability 0.20.2, independentlyRight so far: Problem 6.
  2. “Success within three attempts is success on the first, the second or the third.”Also right; the events are not disjoint, though.
  3. P(X≤3)=0.2+0.2+0.2=0.6P(X \le 3) = 0.2 + 0.2 + 0.2 = 0.6Adding counts the outcomes where two or three attempts would succeed more than once; with six attempts the same rule would give 1.21.2. Go through the complement: P(X≤3)=1−0.83=0.488P(X \le 3) = 1 - 0.8^3 = 0.488.

5. Variances of dependent indicators added as if independent

Problem 4 adds the variances of indicators, and the same move looks fine for the matching problem.

  1. X=I1+⋯+InX = I_1 + \cdots + I_n with Var⁡(Ij)=1n(1−1n)\operatorname{Var}(I_j) = \tfrac1n\big(1 - \tfrac1n\big)Right so far: Problem 5.
  2. “So Var⁡(X)\operatorname{Var}(X) is nn times that.”The step that causes the mistake: it needs the IjI_j to be uncorrelated, and they are not.
  3. Var⁡(X)=1−1n\operatorname{Var}(X) = 1 - \tfrac1n, which is 0.750.75 for n=4n = 4Every pair has a positive covariance 1n(n−1)−1n2\tfrac{1}{n(n - 1)} - \tfrac{1}{n^2}, and the n(n−1)n(n - 1) ordered pairs add 1n\tfrac1n, so Var⁡(X)=1\operatorname{Var}(X) = 1 for every n≥2n \ge 2. Linearity of expectation needs no independence; adding variances does.

Print this set: discrete-random-variables-and-expectation.pdf (problems, answers, and worked solutions on separate pages).

Read the guide: Expected value and variance of a discrete random variable: weight by the probabilities, then square before you average