Four Quick Probability and Inference Problems
Statistics & ExperimentsModel answerLast updated
Four short statistics problems: covariance of the min and max of two uniforms, why sample variance divides by n-1, z-test sample size, and a proof of the one-sided Chebyshev bound.
Answer each of the following four parts. Give the result first, then a concise justification.
Part 1: Min and max of two uniforms.
Draw two independent random variables, each uniform on the interval from 0 to 1. Let U be the smaller of the two and V the larger. Find Cov(U, V).
Part 2: The n-1 in sample variance. The usual sample variance of observations x_1, ..., x_n is
s² = (1 / (n - 1)) · Σ (x_i − x̄)²
Explain why the divisor is n − 1 and not n. Mention what assumptions your argument needs.
Part 3: Sizing a z-test. You want a z-test with significance level α and power 1 − β to detect a true difference of size Δ. Give the formula for the required sample size, show where it comes from, and list the assumptions behind it. Also say how it changes for a two-sample comparison and for a one-sided test.
Part 4: A one-sided tail bound. Let X have mean μ and variance σ². Prove that for every a > 0,
P(X − μ ≥ a) ≤ σ² / (σ² + a²).
Hints
Hint 1
For Part 1, the pair (U, V) is just (X, Y) sorted, so U·V = X·Y and U + V = X + Y. You only need E[U] from the survival function P(U > u) = (1 − u)².
Hint 2
For Parts 2 and 3, start from the identity Σ(x_i − μ)² = Σ(x_i − x̄)² + n(x̄ − μ)² for Part 2. For Part 3, find the distribution of the test statistic when the true effect is Δ, then set the power equation equal to a normal quantile.
Hint 3
For Part 4, center the variable (Y = X − μ), add a free constant t ≥ 0 before squaring so Markov's inequality applies, and then pick the t that minimizes the resulting bound.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Part 1: Cov(U, V) = 1/36
Shortcut. Sorting two numbers does not change their product or sum, so U·V = X·Y and U + V = X + Y.
- Product: E[UV] = E[XY] = E[X]·E[Y] = 1/4, by independence.
- Min: P(U > u) = (1 − u)², so E[U] = ∫₀¹ (1 − u)² du = 1/3.
- Max: E[V] = E[X] + E[Y] − E[U] = 1 − 1/3 = 2/3.
Cov(U, V) = 1/4 − (1/3)(2/3) = 1/4 − 2/9 = 1/36.
Cross-check. The joint density of (U, V) is 2 on the triangle 0 < u < v < 1. Then E[UV] = ∫₀¹ ∫₀^v 2uv du dv = ∫₀¹ v³ dv = 1/4, which agrees.
Extra. Var(U) = Var(V) = 1/18, so the correlation is (1/36)/(1/18) = 1/2. The covariance is positive because a large minimum forces the maximum to be large too.
Common mistakes: treating U and V as independent, dropping the factor 2 in the joint density, and arithmetic slips in 1/4 − 2/9.
Part 2: Why divide by n − 1
Assumptions. The x_i are iid with mean μ and finite variance σ². Normality is not needed for unbiasedness.
Core idea. The deviations are taken around x̄, which is computed from the same data. The sample mean is the point that minimizes the sum of squares, so Σ(x_i − x̄)² is always at most Σ(x_i − μ)². The naive average of squared residuals therefore underestimates σ².
Derivation. Expanding around x̄ gives
Σ(x_i − μ)² = Σ(x_i − x̄)² + n(x̄ − μ)²,
because the cross term contains Σ(x_i − x̄) = 0. Taking expectations:
- left side: nσ²
- last term: n·Var(x̄) = n·σ²/n = σ²
So E[Σ(x_i − x̄)²] = (n − 1)σ², and dividing by n − 1 gives an unbiased estimator.
Degrees of freedom view. The n residuals are forced to sum to zero, so only n − 1 are free. Geometrically, the residual vector is the projection of the data onto the (n − 1)-dimensional subspace orthogonal to the all-ones vector. Under normality this yields (n − 1)s²/σ² ~ χ²_{n−1}.
Caveats worth stating:
- s is still a biased estimator of σ (Jensen: E[s] < σ).
- Unbiased does not mean minimum MSE. For Gaussian data, dividing by n + 1 has the lowest MSE and dividing by n is the MLE.
- If μ is known, divide by n, since no degree of freedom was spent on estimating the mean.
Part 3: z-test sample size
Setup (one-sample, two-sided). Test statistic Z = (x̄ − μ₀)/(σ/√n); reject if |Z| > z_{1−α/2}.
If the true mean is μ₀ + Δ, then Z ~ N(Δ√n/σ, 1). Ignoring the tiny probability of rejecting in the wrong tail,
power ≈ Φ(Δ√n/σ − z_{1−α/2}).
Setting this equal to 1 − β means Δ√n/σ − z_{1−α/2} = z_{1−β}, so
n = (z_{1−α/2} + z_{1−β})² σ² / Δ²
Variants:
- Two independent groups of equal size: Var(x̄₁ − x̄₂) = 2σ²/n, so n per group = 2(z_{1−α/2} + z_{1−β})² σ² / Δ².
- One-sided test: use z_{1−α} in place of z_{1−α/2}.
- Proportions: σ² = p(1 − p). A more careful version uses the pooled proportion under H₀ and the separate proportions under H₁.
Rule of thumb. For α = 0.05 (two-sided) and 80% power, (1.96 + 0.84)² ≈ 7.85, so n per group ≈ 16σ²/Δ².
Assumptions:
- Independent observations (watch for clustering or autocorrelation).
- σ known, or n large enough that estimating it is harmless; otherwise use a t-test and iterate.
- x̄ approximately normal (CLT).
- Δ is fixed in advance and is practically meaningful.
- One planned test; adjust α for multiple comparisons.
Key takeaway. n scales as 1/Δ². Detecting an effect half as large needs four times the data.
Part 4: Cantelli's inequality
Idea. Chebyshev bounds both tails together. To bound only the upper tail, shift the variable by a constant before squaring, then tune the constant.
Proof. Let Y = X − μ, so E[Y] = 0 and E[Y²] = σ². Fix t ≥ 0.
-
If Y ≥ a, then Y + t ≥ a + t > 0, hence (Y + t)² ≥ (a + t)². Therefore P(Y ≥ a) ≤ P((Y + t)² ≥ (a + t)²).
-
Markov's inequality gives P(Y ≥ a) ≤ E[(Y + t)²]/(a + t)² = (σ² + t²)/(a + t)², since E[Y] = 0 kills the cross term.
-
Minimize over t. Setting the derivative to zero gives t(a + t) = σ² + t², so t* = σ²/a. Then
- numerator: σ² + σ⁴/a² = σ²(a² + σ²)/a²
- denominator: (a + σ²/a)² = (a² + σ²)²/a²
The ratio is σ²/(σ² + a²). ∎
Tightness. Take Y = a with probability p = σ²/(σ² + a²) and Y = −σ²/a with probability 1 − p. The mean is (aσ² − σ²a)/(σ² + a²) = 0, and the variance is (a²σ² + σ⁴)/(σ² + a²) = σ². The bound holds with equality, so it cannot be improved using only the mean and variance.
Comparison. Cantelli is always at least as strong as the one-sided use of Chebyshev (σ²/a²), and it is below 1 for every a > 0, whereas Chebyshev is vacuous for a ≤ σ.
Common mistakes: requiring t to be negative (the step a + t > 0 would fail), forgetting that E[Y] = 0 is what removes the cross term, and stopping at t = 0, which just reproduces Chebyshev.