Probability and Descriptive Statistics for Data Science: Counting, Axioms, Conditional Expectation, Covariance and the Named Distributions
Conditioning, Bayes' Theorem, and Conditional Expectation and Variance
Law of total probability: if B₁, …, B_k partition Ω, P(A) = Σ P(A | B_i) P(B_i). Bayes' theorem: P(B_j | A) = P(A | B_j) P(B_j) / Σ_i P(A | B_i) P(B_i). The test example: a condition with prevalence 1%, a test that is positive for 95% of those with it (sensitivity) and for 5% of those without (false-positive rate). P(positive) = 0.01×0.95 + 0.99×0.05 = 0.0590, so P(condition | positive) = 0.0095/0.0590 = 0.1610, only about 16%: the false positives from the large healthy majority outnumber the true positives. That is the base-rate effect, the single most-tested use of Bayes. In odds form, posterior odds = prior odds × likelihood ratio.
Conditional expectation. E[X | Y = y] is the mean of X within the slice Y = y, and E[X | Y] is itself a random variable. Two identities do most of the work: the tower law E[E[X | Y]] = E[X] and the law of total variance Var(X) = E[Var(X | Y)] + Var(E[X | Y]). Example: Y = 1 or 2 with equal probability, X | Y = 1 has mean 10 and variance 4, X | Y = 2 has mean 20 and variance 9. Then E[X] = 15; E[Var(X|Y)] = 6.5; Var(E[X|Y]) = 25; so Var(X) = 6.5 + 25 = 31.5 — far above either conditional variance, because the spread of the group means adds to the spread within groups. For independent X, Y: E[X | Y] = E[X]. Conditional variance Var(X | Y) = E[X² | Y] − (E[X | Y])².
- Condition: 1%
- Positive: 95%0.01 × 0.95 = 0.0095
- No condition: 99%
- Positive: 5%0.99 × 0.05
Law of total probability: if B₁, …, B_k partition Ω, P(A) = Σ P(A | B_i) P(B_i). Bayes' theorem: P(B_j | A) = P(A | B_j) P(B_j) / Σ_i P(A | B_i) P(B_i). The test example: a condition with…
Covariance, Correlation and the Variance of a Sum
Covariance Cov(X, Y) = E[XY] − E[X] E[Y]; correlation ρ = Cov(X, Y)/(σ_X σ_Y) lies in [−1, 1] and is ±1 exactly when Y is a linear function of X. Var(aX + bY) = a² Var X + b² Var Y + 2ab Cov(X, Y), so variances add only for uncorrelated variables. Independent ⇒ uncorrelated, but not the reverse: with X uniform on (−1, 1) and Y = X², Cov(X, Y) = E[X³] − 0 = 0, yet Y is completely determined by X. Worked pmf: P(0,0) = 0.3, P(0,1) = 0.2, P(1,0) = 0.1, P(1,1) = 0.4. Then E[X] = 0.5, E[Y] = 0.6000000000000001, E[XY] = 0.4, so Cov = 0.4 − 0.30 = 0.10, Var X = 0.25, Var Y = 0.24 and ρ = 0.4082. The conditional pmf P(Y = 1 | X = 1) = 0.4/0.5 = 0.8, against the marginal P(Y = 1) = 0.6000000000000001: they differ, so X and Y are not independent, as the non-zero covariance already said.
Descriptive statistics. Mean x̄ = Σx/n; median is the middle value of the sorted data (the average of the middle two when n is even); mode is the most frequent value. Standard deviation: population σ = √(Σ(x − μ)²/N) and sample s = √(Σ(x − x̄)²/(n − 1)), the n − 1 making s² an unbiased estimator. For 2, 4, 4, 4, 5, 5, 7, 9: mean 5, median 4.5, mode 4, Σ(x − x̄)² = 32, σ = 2.000 and s = 2.138. Shifting every value adds to the mean and leaves the SD alone; scaling by c multiplies both mean and SD by |c|. In a right-skewed distribution mean > median > mode; the mean is the least robust of the three to outliers.
Covariance Cov(X, Y) = E[XY] − E[X] E[Y]; correlation ρ = Cov(X, Y)/(σ_X σ_Y) lies in [−1, 1] and is ±1 exactly when Y is a linear function of X. Var(aX + bY) = a² Var X + b² Var Y + 2ab…
Random Variables and the Named Distributions
A discrete random variable has a pmf p(x) = P(X = x) with Σp = 1; a continuous one has a pdf f(x) ≥ 0 with ∫f = 1 and P(a < X < b) = ∫ₐᵇ f; the cdf F(x) = P(X ≤ x) is non-decreasing from 0 to 1, F′ = f. For two continuous variables the marginal is f_X(x) = ∫f(x, y) dy and the conditional pdf is f(x | y) = f(x, y) / f_Y(y); X and Y are independent exactly when f(x, y) = f_X(x) f_Y(y). The named distributions (mean; variance): Bernoulli(p): p; p(1 − p). Binomial(n, p): np; np(1 − p) (n independent Bernoullis). Poisson(λ): λ; λ (rare events; the limit of Binomial with np = λ). Uniform(a, b): (a + b)/2; (b − a)²/12. Exponential(λ): 1/λ; 1/λ², memoryless: P(X > s + t | X > s) = P(X > t). Normal(μ, σ²): μ; σ², with Z = (X − μ)/σ standard normal; Φ(1) = 0.8413, Φ(1.96) = 0.9750, so about 68%, 95% and 99.7% of mass lie within 1, 2 and 3 SD.
Two numerical checks. Poisson approximates the binomial when n is large and p small: for n = 100, p = 0.03, P(X = 2) = 0.2252 exactly, against the Poisson(λ = 3) value 0.2240. For an exponential with rate 0.5 per minute, P(X ≤ 3) = 1 − e^(−1.5) = 0.7769. The variance of Uniform(4, 10) is 36/12 = 3. Choosing the model: counts of successes in a fixed number of trials → binomial; counts of events in a continuous interval → Poisson; time until the next event → exponential; a sum or mean of many small effects → normal.
| Distribution | Mean | Variance |
|---|---|---|
| Bernoulli(p) | p | p(1 − p) |
| Binomial(n, p) | np | np(1 − p) |
| Poisson(λ) | λ | λ |
| Uniform(a, b) | (a + b)/2 | (b − a)²/12 |
| Exponential(λ) | 1/λ | 1/λ² |
| Normal(μ, σ²) | μ | σ² |
- Successes in fixed trialsBinomial
- Events in a continuous intervalPoisson
- Time until the next eventExponential
- Sum or mean of many small effectsNormal
A discrete random variable has a pmf p(x) = P(X = x) with Σp = 1; a continuous one has a pdf f(x) ≥ 0 with ∫f = 1 and P(a < X < b) = ∫ₐᵇ f; the cdf F(x) = P(X ≤ x) is non-decreasing from 0…
Key takeaways
- Counting: nPr = n!/(n − r)! when order matters, nCr when it does not; repeats divide by n_i!. The axioms give P(Aᶜ) = 1 − P(A) and P(A ∪ B) = P(A) + P(B) − P(A ∩ B).
- Mutually exclusive events with positive probability are dependent; independent means P(A ∩ B) = P(A)P(B). Bayes' theorem reverses a conditional and exposes the base-rate effect.
- Tower law E[E[X|Y]] = E[X]; total variance Var X = E[Var(X|Y)] + Var(E[X|Y]); Var(aX + bY) = a²VarX + b²VarY + 2abCov.
- Independent ⇒ uncorrelated but not conversely (X uniform on (−1, 1), Y = X²); correlation lies in [−1, 1], ±1 only for an exact linear relation.
- Memorise mean and variance of Bernoulli, binomial, Poisson, uniform, exponential and normal; sample SD divides by n − 1, population SD by N.
Practice questions (24)
Attempt each one before opening the answer. Every explanation names the tempting wrong option as well as the right one, because that is where marks are lost.
How many distinct arrangements are there of the letters of the word STATISTICS?
Show answer
Answer: C — 50,400
The word has 10 letters with S×3, T×3, I×2, so arrangements = 10!/(3! 3! 2!) = 50400. 10! alone ignores that repeated letters are indistinguishable.Events A and B each have positive probability and are mutually exclusive. Then A and B are:
Show answer
Answer: A — dependent
P(A ∩ B) = 0 but P(A)P(B) > 0, so the product rule fails: they are dependent (A occurring rules B out). Exclusive and independent are different properties.A condition has prevalence 1%. A test is positive for 95% of people with it and for 5% of those without. A person tests positive. The probability they have the condition is nearest to:
Show answer
Answer: C — 16.1%
P(+) = 0.01 × 0.95 + 0.99 × 0.05 = 0.0590; P(D | +) = 0.0095/0.0590 = 0.1610. The 95% answer confuses P(+ | D) with P(D | +).
Show the other 21 questions
Y takes values 1 and 2 with equal probability. Given Y = 1, X has mean 10 and variance 4; given Y = 2, X has mean 20 and variance 9. Find Var(X).
Numerical answer — type the value.
Show answer
Answer: 31.5
Var(X) = E[Var(X|Y)] + Var(E[X|Y]) = (4 + 9)/2 + Var of {10, 20} (equally likely) = 6.5 + 25 = 31.5.For the joint pmf P(0,0) = 0.3, P(0,1) = 0.2, P(1,0) = 0.1, P(1,1) = 0.4, the covariance Cov(X, Y) is:
Show answer
Answer: A — 0.10
E[X] = 0.5, E[Y] = 0.6, E[XY] = 0.4, so Cov = 0.4 − 0.30 = 0.10. The 0.40 option is E[XY] without subtracting E[X]E[Y].Which statement about independence and correlation is correct?
Show answer
Answer: C — independent variables are uncorrelated, but uncorrelated variables need not be independent
Independence gives E[XY] = E[X]E[Y], hence zero covariance. The converse fails: X uniform on (−1, 1) and Y = X² have zero covariance but Y is a function of X. Correlation measures only linear dependence.The sample standard deviation of 2, 4, 4, 4, 5, 5, 7, 9 (divisor n − 1) is nearest to:
Show answer
Answer: C — 2.138
Σ(x − 5)² = 32; the sample variance is 32/7 = 4.571 and s = 2.138. The population SD with divisor 8 is exactly 2.The number of calls arriving at a switchboard in a minute averages 3 and the calls are independent. Which distribution models the count, and what is its variance?
Show answer
Answer: C — Poisson, variance 3
Counts of independent events in a continuous interval are Poisson, with variance equal to the mean, λ = 3. The exponential models the waiting time between calls (mean 1/3 minute), not the count.For an exponential random variable with rate λ, the memoryless property says:
Show answer
Answer: A — P(X > s + t | X > s) = P(X > t)
Having already waited s changes nothing about the remaining wait: the remaining time is again exponential with the same rate. (E[X | X > s] = s + 1/λ, not E[X].)The number of ways to choose a committee of 3 people from 10 is ____.
Numerical answer — type the value.
Show answer
Answer: 120
Order does not matter: C(10, 3) = 120. Counting ordered selections, 10 × 9 × 8 = 720, treats the committee as ranked.The number of subsets (including the empty set) of a set with 5 elements is ____.
Numerical answer — type the value.
Show answer
Answer: 32
Each element is in or out: 2⁵ = 32. Answering 31 leaves out the empty set; 25 squares instead of raising 2 to the power.The expected value of the score on one roll of a fair six-sided die is ____.
Numerical answer — type the value.
Show answer
Answer: 3.5
E = (1 + 2 + … + 6)/6 = 21/6 = 3.5, a value the die can never show. Rounding to 3 or 4 confuses expectation with a possible outcome.X is binomial with n = 20 trials and success probability p = 0.3. Its mean is ____.
Numerical answer — type the value.
Show answer
Answer: 6
E[X] = np = 20 × 0.3 = 6 successes on average. The variance np(1 − p) = 4.2 is the tempting neighbour.For events A and B with P(B) > 0, the conditional probability P(A | B) equals:
Show answer
Answer: A — P(A ∩ B)/P(B)
Conditioning on B restricts the sample space to B. Dividing by P(A) gives P(B | A), the classic reversal; P(A)P(B) holds only under independence.If Var(X) = 4, then Var(3X + 5) is ____.
Numerical answer — type the value.
Show answer
Answer: 36
Var(aX + b) = a² Var(X) = 9 × 4 = 36; adding a constant does not change spread. Answering 17 (3 × 4 + 5) treats variance like the mean.Urn 1 has 3 red and 2 blue balls; urn 2 has 1 red and 4 blue. An urn is chosen at random and a ball drawn from it is red. The probability that it came from urn 1 is ____.
Numerical answer — type the value.
Show answer
Answer: 0.75
Bayes: (0.5 × 0.6)/(0.5 × 0.6 + 0.5 × 0.2) = 0.3/0.4 = 0.75. Answering 0.6 confuses P(red | urn 1) with the answer.X is Poisson with mean 2. P(X = 0), to three decimals, is ____.
Numerical answer — type the value.
Show answer
Answer: 0.135
P(0) = e^(−2) = 0.135. Using e^(−1/2) treats 2 as the mean waiting time rather than the rate.The number of distinct arrangements of the letters of LEVEL is ____.
Numerical answer — type the value.
Show answer
Answer: 30
Five letters with L and E each twice: 5!/(2! 2!) = 30. Dividing by only one 2! gives 60.Var(X) = 4, Var(Y) = 9 and Cov(X, Y) = 2. Then Var(X + Y) is ____.
Numerical answer — type the value.
Show answer
Answer: 17
Var(X + Y) = 4 + 9 + 2 × 2 = 17. Answering 13 drops the covariance term, which is valid only for uncorrelated variables.X is uniformly distributed on [0, 10]. Its variance, to two decimals, is ____.
Numerical answer — type the value.
Show answer
Answer: 8.33
Var = (b − a)²/12 = 100/12 = 8.33. Using /6 gives 16.67; reporting the standard deviation gives 2.89.A fair die is rolled 4 times. The probability of at least one six, to three decimals, is ____.
Numerical answer — type the value.
Show answer
Answer: 0.518
Use the complement: 1 − (5/6)⁴ = 1 − 0.482 = 0.518. Adding 4 × 1/6 = 0.667 double-counts rolls with several sixes.X is normal with mean 50 and variance 100. P(X > 65), to four decimals, is ____.
Numerical answer — type the value.
Show answer
Answer: 0.0668
σ = 10, so z = 1.5 and P = 1 − Φ(1.5) = 0.0668. Using the variance as σ gives z = 0.15 and about 0.44, the tempting slip.Two fair dice are rolled. The expected value of the larger of the two scores, to three decimals, is ____.
Numerical answer — type the value.
Show answer
Answer: 4.472
P(max ≤ k) = (k/6)², so P(max = k) = (2k − 1)/36 and E = Σ k(2k − 1)/36 = 161/36 = 4.472. Answering 3.5 ignores that the maximum is skewed upward.Which of the following statements about standard distributions are correct? (More than one may be correct.)
Show answer
Answer: A — A Poisson variable has mean equal to its variance; B — A binomial(n, p) variable has variance np(1 − p); D — The geometric distribution is memoryless
The first three are correct; the geometric is the discrete analogue of the memoryless exponential. The last is the trap: the uniform variance is (b − a)²/12.