Statistics Interview Questions Explained
Statistics is the backbone of data science. While you can learn to run Python code that calculates statistics, interviewers want to know that you understand what those numbers mean and when to use them. This guide covers the essential statistics concepts you need to master for data science interviews.
Descriptive Statistics
Measures of Central Tendency
Mean: The arithmetic average. Sensitive to outliers.
Median: The middle value when sorted. Robust to outliers.
Mode: The most frequent value. Useful for categorical data.
Interview Question: When would you use median instead of mean?
Use median when your data has significant outliers or is heavily skewed. Income data is a classic example: a few very high earners can dramatically inflate the mean, making median a better measure of typical income.
Measures of Spread
Variance: Average squared deviation from the mean. Units are squared.
Standard Deviation: Square root of variance. Same units as original data.
Range: Difference between max and min. Highly sensitive to outliers.
Interquartile Range (IQR): Q3 - Q1. Robust to outliers.
# Python example
import numpy as np
data = [10, 12, 23, 23, 16, 23, 21, 16]
mean = np.mean(data) # 18.0
median = np.median(data) # 18.5
std_dev = np.std(data, ddof=1) # Sample std deviation
variance = np.var(data, ddof=1)
Probability Foundations
Basic Probability Rules
Addition Rule: P(A or B) = P(A) + P(B) - P(A and B)
Multiplication Rule: P(A and B) = P(A) * P(B|A)
Complement Rule: P(not A) = 1 - P(A)
Interview Question: What is the difference between independent and mutually exclusive events?
Independent events: One event occurring does not affect the probability of the other. P(A and B) = P(A) * P(B). Example: Two separate coin flips.
Mutually exclusive events: If one occurs, the other cannot. P(A and B) = 0. Example: Getting heads and tails on the same flip.
Important: Mutually exclusive events cannot be independent (unless one has probability zero).
Conditional Probability and Bayes Theorem
Conditional probability P(A|B) means the probability of A given that B has occurred.
Bayes Theorem: P(A|B) = P(B|A) * P(A) / P(B)
Classic Interview Question: A medical test has 99% sensitivity (true positive rate) and 99% specificity (true negative rate). If 1% of the population has the disease, what is the probability someone has the disease given a positive test?
# Solution using Bayes Theorem
P_disease = 0.01 # Prior probability
P_positive_given_disease = 0.99 # Sensitivity
P_positive_given_no_disease = 0.01 # 1 - Specificity
# P(positive) = P(positive|disease)*P(disease) + P(positive|no disease)*P(no disease)
P_positive = (0.99 * 0.01) + (0.01 * 0.99)
P_positive = 0.0198
# P(disease|positive) = P(positive|disease) * P(disease) / P(positive)
P_disease_given_positive = (0.99 * 0.01) / 0.0198
# Result: 0.50 or 50%
# Despite 99% accuracy, only 50% chance of actually having disease!
Probability Distributions
Normal Distribution
The bell curve. Characterized by mean and standard deviation. Many natural phenomena follow this distribution.
68-95-99.7 Rule:
- 68% of data falls within 1 standard deviation of the mean
- 95% within 2 standard deviations
- 99.7% within 3 standard deviations
Interview Question: What is the Central Limit Theorem?
The Central Limit Theorem states that the sampling distribution of the sample mean approaches a normal distribution as sample size increases, regardless of the population distribution. This is why normal-based statistical methods work even when data is not normally distributed, as long as sample sizes are large enough (typically n > 30).
Binomial Distribution
Models the number of successes in n independent trials, each with probability p of success. Example: Number of heads in 10 coin flips.
from scipy import stats
# Probability of exactly 7 heads in 10 fair coin flips
prob = stats.binom.pmf(7, n=10, p=0.5) # 0.117
# Probability of 7 or more heads
prob_7_or_more = 1 - stats.binom.cdf(6, n=10, p=0.5) # 0.172
Poisson Distribution
Models the number of events occurring in a fixed interval when events happen at a constant average rate. Example: Number of customer arrivals per hour.
When to Use Each Distribution
- Normal: Continuous data, symmetric, many natural measurements
- Binomial: Count of successes in fixed number of trials
- Poisson: Count of events in a time/space interval
- Exponential: Time between events in a Poisson process
Hypothesis Testing
The Framework
- State hypotheses: Null hypothesis (H0) and alternative hypothesis (H1)
- Choose significance level: Usually alpha = 0.05
- Collect data and calculate test statistic
- Calculate p-value
- Make decision: Reject or fail to reject H0
Interview Question: What is a p-value?
A p-value is the probability of observing results as extreme as (or more extreme than) what we observed, assuming the null hypothesis is true. It is NOT the probability that the null hypothesis is true.
If p-value < alpha, we reject the null hypothesis. A low p-value means our observed data would be unlikely if the null hypothesis were true.
Type I and Type II Errors
Type I Error (False Positive): Rejecting H0 when it is actually true. Probability = alpha.
Type II Error (False Negative): Failing to reject H0 when it is actually false. Probability = beta.
Power: 1 - beta. The probability of correctly rejecting a false null hypothesis.
Common Statistical Tests
Z-test: Compare sample mean to population mean when population std dev is known and n is large.
T-test: Compare means when population std dev is unknown or sample is small.
Chi-square test: Test for independence between categorical variables.
ANOVA: Compare means across more than two groups.
from scipy import stats
# Two-sample t-test
group_a = [23, 25, 28, 22, 26]
group_b = [30, 32, 29, 35, 31]
t_stat, p_value = stats.ttest_ind(group_a, group_b)
print(f't-statistic: {t_stat:.3f}, p-value: {p_value:.3f}')
Confidence Intervals
Interview Question: What is a 95% confidence interval?
A 95% confidence interval means that if we repeated our sampling procedure many times, 95% of the calculated intervals would contain the true population parameter. It does NOT mean there is a 95% probability the true value is in this specific interval.
# Calculate 95% CI for mean
import numpy as np
from scipy import stats
data = [23, 25, 28, 22, 26, 24, 27, 25]
mean = np.mean(data)
se = stats.sem(data) # Standard error
ci = stats.t.interval(0.95, len(data)-1, loc=mean, scale=se)
print(f'95% CI: ({ci[0]:.2f}, {ci[1]:.2f})')
A/B Testing
Designing an A/B Test
- Define the hypothesis: What change are you testing? What metric will you measure?
- Calculate sample size: Based on baseline conversion, minimum detectable effect, desired power
- Randomize properly: Ensure groups are comparable
- Run the test: Until you reach required sample size (not until you see significance)
- Analyze results: Calculate statistical significance and practical significance
Sample Size Calculation
from statsmodels.stats.power import TTestIndPower
# Parameters
effect_size = 0.2 # Expected difference in standard deviations
alpha = 0.05 # Significance level
power = 0.8 # Desired power
# Calculate required sample size per group
analysis = TTestIndPower()
sample_size = analysis.solve_power(effect_size=effect_size,
alpha=alpha,
power=power)
print(f'Required sample size per group: {int(sample_size)}')
Interview Question: When should you stop an A/B test?
You should determine sample size before starting and run until you reach it. Do NOT stop early just because you see statistical significance (this inflates false positive rate). Do NOT keep running past your planned sample size hoping to achieve significance (this is p-hacking).
You CAN use sequential testing methods that allow for valid early stopping, but these must be planned in advance.
Regression
Linear Regression
Models the relationship between a dependent variable and one or more independent variables.
Y = beta0 + beta1*X1 + beta2*X2 + ... + error
Interview Question: How do you interpret regression coefficients?
Each coefficient represents the expected change in Y for a one-unit increase in that X, holding all other variables constant. For example, if beta1 = 2.5 for years of experience predicting salary, each additional year of experience is associated with $2,500 higher salary (assuming salary is in thousands).
R-squared and Adjusted R-squared
R-squared: Proportion of variance in Y explained by the model. Range 0 to 1. Higher is better, but always increases when adding variables.
Adjusted R-squared: Penalizes for adding variables that do not improve the model. Better for comparing models with different numbers of predictors.
Common Issues in Regression
Multicollinearity: When predictors are highly correlated with each other. Makes coefficients unstable. Check with VIF (Variance Inflation Factor).
Heteroscedasticity: When error variance is not constant. Violates regression assumptions. Check by plotting residuals vs fitted values.
Overfitting: Model fits training data too well but performs poorly on new data. Use cross-validation and regularization.
Correlation vs Causation
Interview Question: Does correlation imply causation?
No. Correlation shows that two variables move together, but not that one causes the other. There could be:
- Reverse causation: B causes A, not A causes B
- Confounding variable: C causes both A and B
- Coincidence: Spurious correlation with no real relationship
To establish causation, you need randomized controlled experiments or careful causal inference techniques.
Key Formulas to Know
Standard Error of Mean: SE = s / sqrt(n)
Z-score: z = (x - mean) / std_dev
Coefficient of Variation: CV = std_dev / mean
Effect Size (Cohen's d): d = (mean1 - mean2) / pooled_std_dev
Tips for Statistics Interview Questions
- Explain concepts simply: Avoid jargon, use examples
- Know assumptions: For each test, know when it applies
- Think practically: Statistical significance vs practical significance
- Ask clarifying questions: What is the business context?
When preparing your resume for data science roles, highlight any experience with statistical analysis, A/B testing, or experimental design to demonstrate your quantitative foundation.