Probability and Regression Fundamentals: A Rapid-Fire Review
Statistics & ExperimentsModel answerLast updated
A multi-part conceptual review covering dice probabilities, variance estimation, correlation versus independence, OLS and regularization, multicollinearity, and PCA.
Answer each of the following short theory questions. Equations and brief examples are welcome. Be precise: state conditions and mention standard counterexamples where they exist.
Part A: Probability
- Two fair six-sided dice are rolled.
- What is the probability that the two values differ, so that one die is strictly larger than the other?
- What is the probability that one particular die (say, the first) shows a strictly larger value than the other?
Part B: Descriptive statistics
- Define the mean and the variance of a random variable.
- Is the common "divide by n" sample variance biased? If so, what adjustment makes it unbiased?
Part C: Correlation and independence
- Suppose X and Y each have a normal marginal distribution and Corr(X, Y) = 0. Must they be independent? Under what condition does zero correlation guarantee independence?
Part D: Linear regression
- Describe linear regression and list the standard assumptions behind Ordinary Least Squares (OLS).
- Give the closed-form OLS estimator.
- Why does multicollinearity cause trouble? How do you detect it, and how can you reduce it?
- Explain Ridge and Lasso regression, and how each relates to collinearity.
Part E: Principal Component Analysis
- Explain what PCA does and how it works.
- In the PCA setting, what do eigenvalues and eigenvectors represent?
- What are the main limitations of PCA?
Hints
Hint 1
For the dice, count ordered outcomes out of 36 and remember that ties exist. Symmetry splits the non-tied outcomes evenly between the two dice.
Hint 2
For zero correlation versus independence, build a counterexample with Y = W·X where W is a random sign independent of X. Then recall what extra property of the joint distribution makes the implication true.
Hint 3
For regression, connect everything through the matrix XᵀX: collinearity makes it nearly singular, ridge adds λI to fix it, and PCA is an eigen-decomposition of a closely related matrix.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Model answer
1. Two dice
There are 36 equally likely ordered outcomes, and 6 of them are ties.
- Values differ (one is strictly larger): (36 − 6)/36 = 5/6.
- A specific die is strictly larger: the 30 non-tied outcomes split evenly by symmetry, so 15/36 = 5/12. Direct check: if the first die shows k, the second has k − 1 options, and 0+1+2+3+4+5 = 15.
Common mistake: answering 1/2 for the second part, which ignores ties.
2. Mean and variance
- Mean: E[X] = Σ x·p(x) (discrete) or ∫ x f(x) dx (continuous); the balance point of the distribution.
- Variance: Var(X) = E[(X − μ)²] = E[X²] − (E[X])². Standard deviation is its square root and shares X's units.
- Useful rules: Var(aX + b) = a²Var(X); Var(X + Y) = Var(X) + Var(Y) + 2Cov(X, Y).
3. Bias of sample variance
The divide-by-n estimator σ̂² = (1/n)Σ(xᵢ − x̄)² is biased: E[σ̂²] = ((n − 1)/n)σ². The sample mean is fitted to the same data, so deviations around x̄ are systematically smaller than around the true μ (one degree of freedom is used up).
Bessel's correction divides by n − 1, giving s² with E[s²] = σ². Nuances: s is still a biased estimator of σ (Jensen, since √ is concave), and the 1/n version can have lower mean squared error, so unbiased does not mean best.
4. Zero correlation vs. independence
Not necessarily. Correlation captures only linear association.
Counterexample: X ~ N(0,1), W = ±1 with equal probability and independent of X, Y = WX. Then Y ~ N(0,1) and Cov(X, Y) = E[W]E[X²] = 0, yet |Y| = |X|, so they are strongly dependent. (X, Y) is not bivariate normal, since X + Y equals 0 with probability 1/2. Another example is Y = X².
Condition: if X and Y are jointly normal, zero correlation implies independence, because the joint density factorizes when the off-diagonal covariance is zero. Independence always implies zero correlation, but not the reverse.
5. Linear regression and OLS assumptions
The model is y = Xβ + ε, and OLS minimizes ‖y − Xβ‖². Assumptions:
- Linear in the parameters (features may be transformed).
- Independent observations (random sampling).
- No perfect multicollinearity (X has full column rank).
- Exogeneity: E[ε | X] = 0.
- Homoscedasticity: Var(ε | X) = σ²I.
- Uncorrelated errors.
- Normal errors, needed only for exact small-sample t and F tests, not for unbiasedness.
Under 1–6, Gauss–Markov makes OLS the BLUE. Violating 5 leaves coefficients unbiased but standard errors wrong (use robust HC errors). Violating 4 biases the coefficients.
6. Closed form
Setting the gradient −2Xᵀ(y − Xβ) to zero gives the normal equations XᵀXβ = Xᵀy, so
β̂ = (XᵀX)⁻¹Xᵀy, with Var(β̂) = σ²(XᵀX)⁻¹.
In practice use QR or SVD rather than explicitly inverting XᵀX, for numerical stability.
7. Multicollinearity
Problem: correlated features make XᵀX nearly singular; small eigenvalues blow up (XᵀX)⁻¹ and hence Var(β̂). Coefficients become unstable (may flip sign with small data changes), intervals widen, and individual effects are hard to interpret. Predictions within the training distribution are often still fine. Perfect collinearity makes β̂ non-unique.
Detection:
- Pairwise correlation matrix (misses multi-way relations).
- Variance Inflation Factor VIFⱼ = 1/(1 − Rⱼ²); above roughly 5–10 is a warning.
- Condition number or eigenvalues of XᵀX.
- Symptoms: significant F-test but insignificant individual t-tests, coefficients that shift when variables are added or dropped.
Mitigation: drop or merge redundant features, use PCA regression or PLS, center variables before building polynomial or interaction terms, collect more data, or apply regularization.
8. Ridge and Lasso
Ridge (L2): minimize ‖y − Xβ‖² + λ‖β‖₂², giving β̂ = (XᵀX + λI)⁻¹Xᵀy. Adding λI raises every eigenvalue by λ, so the matrix is always invertible and well conditioned. Coefficients shrink toward zero but not exactly to zero, and correlated features share weight. It trades a little bias for a large variance reduction.
Lasso (L1): minimize ‖y − Xβ‖² + λ‖β‖₁. It sets some coefficients exactly to zero (feature selection), has no closed form (use coordinate descent), and among correlated features tends to pick one arbitrarily and unstably.
Elastic Net mixes both, giving sparsity with grouping. For all three, standardize features first and tune λ by cross-validation.
9. PCA
PCA finds orthogonal directions of maximal variance. Steps:
- Center (and usually standardize) the data.
- Compute the covariance matrix Σ (or take the SVD of the centered data).
- Eigen-decompose Σ and sort by eigenvalue.
- Project onto the top k eigenvectors to get a k-dimensional representation.
Choose k via explained variance ratio (for example 90–95%), a scree plot, or cross-validation on a downstream task. PCA also gives the best rank-k linear reconstruction in the least-squares sense.
10. Eigenvalues and eigenvectors in PCA
- Eigenvectors of Σ are the principal axes: orthogonal directions along which the data is uncorrelated.
- Eigenvalues are the variances of the data along those axes. The fraction λᵢ/Σλⱼ is the share of total variance explained by component i.
- Tiny eigenvalues indicate near-redundant directions, which links PCA directly to collinearity.
11. Limitations
- Only linear structure is captured (consider kernel PCA, autoencoders, or UMAP for nonlinear structure).
- Scale-sensitive: unstandardized features with large units dominate.
- Variance is not relevance: high-variance directions may be irrelevant to the target, and PCA is unsupervised (consider PLS or LDA).
- Components are mixtures of all features, hurting interpretability.
- Sensitive to outliers (consider robust PCA).
- Best suited to roughly continuous, centered data; categorical data needs other treatment.
- Components may be unstable when eigenvalues are close.