Probability and Descriptive Statistics for Data Science: Counting, Axioms, Conditional Expectation, Covariance and the Named Distributions

Section 1 of the Data Science and AI paper — Probability and Statistics — is the largest of the three mathematics sections, and the shared Engineering-Mathematics probability chapter was written for engineers; it never taught counting, the axioms, conditional expectation and variance, covariance and correlation, Bernoulli and conditional densities. This chapter does, and the next chapter takes up sampling distributions and the tests. Probability in this paper is a small set of rules used repeatedly: the three axioms (non-negativity, total mass 1, additivity over mutually exclusive events) from which every other rule follows; conditioning (P(A|B) = P(A∩B)/P(B)) and Bayes' theorem, which reverses it; expectation, which is linear whatever the dependence; and the variance of a sum, which is not linear unless the covariance vanishes. The named distributions are then just bookkeeping: each has a mean, a variance and a story. Computed here: the letters of STATISTICS can be arranged in 50,400 ways; a 95%-sensitive, 5%-false-positive test for a 1% condition gives a posterior of only 16.1%; the variance of a mixture is 31.5 although each component's is at most 9; and the data 2, 4, 4, 4, 5, 5, 7, 9 have population SD 2.000 and sample SD 2.138.
Overview

Counting, Sample Spaces and the Axioms

2 min read · 3 parts

Counting. Multiplication principle: independent stages multiply. Permutations of r from n distinct objects (order matters): nPr = n!/(n − r)!; combinations (order does not): nCr = n!/(r!(n − r)!). Arrangements of n objects with repeats: n!/(n₁! n₂! …). So STATISTICS (S×3, T×3, I×2, A, C) can be arranged in 10!/(3! 3! 2!) = 50,400 ways; choosing 5 cards from 52 gives C(52, 5) = 2,598,960 hands, while ordering 5 distinct objects gives 5! = 120. Choosing a 2-person committee from 8 is C(8, 2) = 28, but electing a president and a secretary from 8 is 8P2 = 56: the one question that sorts them is does order matter? Sample space and events. The sample space Ω is the set of all outcomes; an event is a subset. With equally likely outcomes P(A) = |A|/|Ω|, which is why counting is the first topic of probability.

The axioms (Kolmogorov):
(1) P(A) ≥ 0;
(2) P(Ω) = 1;
(3) for mutually exclusive events, P(A ∪ B) = P(A) + P(B) (and countably many). Everything else is derived: P(Aᶜ) = 1 − P(A); P(∅) = 0; P(A ∪ B) = P(A) + P(B) − P(A ∩ B) (inclusion–exclusion); A ⊆ B implies P(A) ≤ P(B). Mutually exclusive means A ∩ B = ∅ (cannot both happen); independent means P(A ∩ B) = P(A) P(B) (knowing one does not change the other). They are different, and nearly opposite: two mutually exclusive events with positive probabilities are always dependent, because if A happens B certainly does not. Marginal probability is P(A) summed over everything else; joint is P(A ∩ B); conditional is P(A | B) = P(A ∩ B)/P(B). Independence of three or more events needs every sub-collection to factorise, not just pairs.

Mutually exclusive vs independent
Mutually exclusive
  • A ∩ B = ∅
  • Cannot both happen
  • P(A ∪ B) = P(A) + P(B)
Independent
  • P(A ∩ B) = P(A) P(B)
  • Knowing one does not change the other
  • Three or more: every sub-collection factorises
With positive probabilities, mutually exclusive events are always dependent.

Counting. Multiplication principle: independent stages multiply. Permutations of r from n distinct objects (order matters): nPr = n!/(n − r)!; combinations (order does not): nCr = n!/(r!(n…

Conditioning, Bayes' Theorem, and Conditional Expectation and Variance

1 min read · 3 parts

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])².

The test example as a tree
Population
  • Condition: 1%
    • Positive: 95%0.01 × 0.95 = 0.0095
  • No condition: 99%
    • Positive: 5%0.99 × 0.05
P(positive) = 0.0590, so P(condition | positive) = 0.0095/0.0590 = 0.1610.

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

1 min read · 2 parts

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

2 min read · 2 parts

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.

DistributionMeanVariance
Bernoulli(p)pp(1 − p)
Binomial(n, p)npnp(1 − p)
Poisson(λ)λλ
Uniform(a, b)(a + b)/2(b − a)²/12
Exponential(λ)1/λ1/λ²
Normal(μ, σ²)μσ²
🎯 Covariance and total expectation, checked
Cov(X, Y) = E[XY] − E[X]E[Y] and Var(X + Y) = Var X + Var Y + 2 Cov(X, Y). If X is Bernoulli(½) and Y = X then Cov = ½ − ¼ = ¼, correlation 1, and Var(X + Y) = Var(2X) = 4 × ¼ = 1, which is ¼ + ¼ + 2 × ¼. The law of total expectation E[X] = E[E[X | Y]] lets a mean be computed by conditioning: a die roll followed by that many coin tosses has E[heads] = E[N]/2 = 3.5/2 = 1.75.
Choosing the model
What is being measured?
  • 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.

  1. How many distinct arrangements are there of the letters of the word STATISTICS?

    1. 151 200
    2. 3 628 800
    3. 50,400
    4. 10 080
    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.
  2. Events A and B each have positive probability and are mutually exclusive. Then A and B are:

    1. dependent
    2. independent
    3. independent only if P(A) = P(B)
    4. sometimes independent, depending on Ω
    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.
  3. 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:

    1. 50%
    2. 95%
    3. 16.1%
    4. 5%
    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
  1. 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.
  2. 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:

    1. 0.10
    2. 0.40
    3. 0.25
    4. 0
    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].
  3. Which statement about independence and correlation is correct?

    1. independent variables have correlation 1
    2. uncorrelated variables are always independent
    3. independent variables are uncorrelated, but uncorrelated variables need not be independent
    4. correlation of 0 implies Y is constant
    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.
  4. The sample standard deviation of 2, 4, 4, 4, 5, 5, 7, 9 (divisor n − 1) is nearest to:

    1. 4.571
    2. 2.000
    3. 2.138
    4. 5.000
    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.
  5. 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?

    1. Exponential, variance 3
    2. Normal, variance 3
    3. Poisson, variance 3
    4. Binomial, variance 9
    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.
  6. For an exponential random variable with rate λ, the memoryless property says:

    1. P(X > s + t | X > s) = P(X > t)
    2. Var(X) = E[X]
    3. E[X | X > s] = E[X]
    4. P(X > s + t) = P(X > s) + P(X > t)
    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].)
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. For events A and B with P(B) > 0, the conditional probability P(A | B) equals:

    1. P(A ∩ B)/P(B)
    2. P(A ∩ B)/P(A)
    3. P(A)P(B)
    4. P(A) + P(B)
    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.
  12. 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.
  13. 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.
  14. 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.
  15. 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.
  16. 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.
  17. 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.
  18. 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.
  19. 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.
  20. 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.
  21. Which of the following statements about standard distributions are correct? (More than one may be correct.)

    1. A Poisson variable has mean equal to its variance
    2. A binomial(n, p) variable has variance np(1 − p)
    3. A uniform(a, b) variable has variance (b − a)²/6
    4. The geometric distribution is memoryless
    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.