[Data Science]
Practical Statistics for Data Scientists — Quiz
This is a self-assessment covering everything from Chapters 1 through 7. Problems are organized into concept checks, calculations, code interpretation, and real-world scenarios. Answers are at the end of each part. Try solving them on your own before peeking at the solutions.
Difficulty: ⭐ Beginner / ⭐⭐ Intermediate / ⭐⭐⭐ Applied
Part 1 — Descriptive Statistics and Data Exploration (Chapter 1)#
Problem 1-1 ⭐ Concept Check#
Find the mean, median, and mode of the following dataset.
Problem 1-2 ⭐ Calculation#
Calculate the sample variance and sample standard deviation for the data below.
Sample variance formula:
Problem 1-3 ⭐ Concept Check#
Which of the following pairs are robust measures of central tendency and spread (resistant to outliers)?
- Mean, Variance
- Median, IQR
- Mean, Standard Deviation
- Mode, Range
Problem 1-4 ⭐⭐ Code Reading#
Read the code below and predict the output.
import numpy as np
data = np.array([10, 20, 20, 30, 40, 50, 50, 50, 100])
print(np.mean(data))
print(np.median(data))
print(np.percentile(data, 75) - np.percentile(data, 25))
Part 2 — Sampling Distributions and Probability Distributions (Chapter 2)#
Problem 2-1 ⭐ Concept Check#
Fill in the blanks.
According to the Central Limit Theorem (CLT), regardless of the population's distribution, when the sample size is sufficiently large, the distribution of the sample mean approaches ___. In this case, the standard deviation of the sample mean (standard error) is ___.
Problem 2-2 ⭐ Calculation#
A population has mean and standard deviation .
(a) When drawing a sample of , what is the standard error of the sample mean?
(b) What is the probability that the sample mean is 52 or greater? (Compute the z-score and use )
Problem 2-3 ⭐⭐ Concept Comparison#
Explain the following about bootstrap:
- What is bootstrap?
- Does it use sampling with replacement or without replacement?
- In what situations is bootstrap particularly useful?
Problem 2-4 ⭐⭐ Calculation#
For a binomial distribution , find the following.
(a) and
(b) Express using the formula below.
Part 3 — Statistical Experiments and Significance Testing (Chapter 3)#
Problem 3-1 ⭐ Concept Check#
Which of the following is the correct interpretation of a p-value?
- The p-value is the probability that the null hypothesis is true.
- The p-value is the probability that the alternative hypothesis is true.
- The p-value is the probability of observing a result as extreme as (or more extreme than) the current one, assuming the null hypothesis is true.
- If p < 0.05, the effect is practically large.
Problem 3-2 ⭐⭐ Scenario#
A pharmaceutical company wants to test whether a new drug is more effective than the existing one.
(a) State the null hypothesis () and the alternative hypothesis ().
(b) Should you use a one-tailed test or a two-tailed test? Explain your reasoning.
(c) Explain what a Type I error and a Type II error each mean in this context.
Problem 3-3 ⭐⭐ Calculation#
You are comparing conversion rates across three marketing channels (A, B, C), each with a sample size of 100.
Which statistical test should you use, and what is the null hypothesis?
If the F-statistic is large and p < 0.05, what is the next step?
Problem 3-4 ⭐⭐⭐ Applied#
Explain the difference between A/B testing and Multi-Armed Bandit (MAB), and give one scenario where each is more appropriate.
Part 4 — Regression and Prediction (Chapter 4)#
Problem 4-1 ⭐ Code Reading#
Read the regression output below and answer the questions.
OLS Regression Results
===========================================================
Dep. Variable: Sales R-squared: 0.782
===========================================================
coef std err t P>|t|
-----------------------------------------------------------
const 12.450 3.210 3.88 0.000
AdSpend 2.345 0.180 13.03 0.000
Employees 1.820 0.650 2.80 0.006
Age -0.430 0.210 -2.05 0.043
===========================================================
(a) On average, how much does Sales change when AdSpend increases by 1 unit?
(b) What percentage of the variation in Sales does this model explain?
(c) Interpret the sign and meaning of the Age coefficient.
(d) At a significance level of 0.05, are there any statistically insignificant variables?
Problem 4-2 ⭐⭐ Concept Comparison#
| Concept | Description |
|---|---|
| RMSE | ? |
| ? | |
| Confidence Interval | ? |
| Prediction Interval | ? |
Fill in each blank, then explain which is wider — the confidence interval or the prediction interval — and why.
Problem 4-3 ⭐⭐ Calculation#
In a simple linear regression , the following data are given.
(a) Find .
(b) Find .
(c) What is when ?
Problem 4-4 ⭐⭐⭐ Residual Diagnostics#
Diagnose the issue in each of the following residual plot descriptions.
- Situation A: In the residuals-vs-fitted plot, the residuals fan out as fitted values increase (funnel shape).
- Situation B: In the QQ plot, both tails deviate significantly from the diagonal line.
- Situation C: In the leverage-residual plot, there is a single point in the upper-right corner.
For each situation, identify which regression assumption is being violated and suggest how to address it.
Part 5 — Classification (Chapter 5)#
Problem 5-1 ⭐ Calculation#
Using the confusion matrix below, calculate accuracy, sensitivity (recall), precision, and F1 score.
| Predicted Positive | Predicted Negative | |
|---|---|---|
| Actual Positive | 80 | 20 |
| Actual Negative | 10 | 90 |
Problem 5-2 ⭐⭐ Concept Check#
In logistic regression, explain the following.
(a) The difference between odds and odds ratio.
(b) How to interpret the coefficient (use ).
(c) Why does logistic regression use the logit instead of directly regressing on probabilities?
Problem 5-3 ⭐⭐ Concept Comparison#
Compare Naive Bayes and Logistic Regression from the following perspectives.
| Aspect | Naive Bayes | Logistic Regression |
|---|---|---|
| Probability estimation | ? | ? |
| Key assumption | ? | ? |
| Advantages | ? | ? |
| Disadvantages | ? | ? |
Problem 5-4 ⭐⭐⭐ Scenario#
You are developing a cancer diagnosis model. 3% of all patients test positive for cancer.
(a) What is the accuracy of a model that always predicts "negative"?
(b) Why is that number meaningless, and what metrics should you use instead?
(c) In this problem, which is more serious — a Type I error (classifying a positive as negative) or a Type II error (classifying a negative as positive)? Explain your reasoning.
(d) Describe three methods for addressing class imbalance.
Part 6 — Statistical Machine Learning (Chapter 6)#
Problem 6-1 ⭐ Concept Check#
Answer the following questions about the KNN algorithm.
(a) What are the problems when is too small (e.g., ) versus too large (e.g., )?
(b) Explain why feature scaling is essential in KNN, using an example.
(c) Why is cosine distance more appropriate than Euclidean distance for text classification?
Problem 6-2 ⭐⭐ Code Reading#
Read the code below and answer the questions.
from sklearn.tree import DecisionTreeClassifier
dt = DecisionTreeClassifier(max_depth=None, random_state=42)
dt.fit(X_train, y_train)
print(dt.score(X_train, y_train)) # Output: 1.0
print(dt.score(X_test, y_test)) # Output: 0.71
(a) What does a training accuracy of 1.0 indicate?
(b) Propose at least two ways to fix this.
(c) Explain why Random Forest outperforms a single decision tree from the perspective of the bias-variance tradeoff.
Problem 6-3 ⭐⭐ Concept Comparison#
Compare bagging and boosting.
| Aspect | Bagging | Boosting |
|---|---|---|
| Training order | ? | ? |
| Error primarily reduced | ? | ? |
| Sensitivity to outliers | ? | ? |
| Representative algorithm | ? | ? |
Problem 6-4 ⭐⭐⭐ Applied#
When training a gradient boosting model, how should you adjust hyperparameters in each of the following situations?
- Situation A: Training accuracy is 0.98, test accuracy is 0.72 (overfitting)
- Situation B: Both training and test accuracy are 0.73 (underfitting)
- Situation C: The model is too slow to deploy
Part 7 — Unsupervised Learning (Chapter 7)#
Problem 7-1 ⭐ Concept Check#
Which of the following statements about PCA is incorrect?
- PCA projects data in the direction that maximizes variance.
- The principal components are orthogonal to each other.
- Standardization before PCA is optional.
- The number of principal components is determined at the elbow point of the scree plot.
Problem 7-2 ⭐⭐ Calculation#
In K-means clustering, the following data points and initial centroids are given.
(a) Find the cluster assignment for each point after one iteration. (Use Euclidean distance.)
(b) Calculate the new centroids.
Problem 7-3 ⭐⭐ Concept Comparison#
Compare K-means and hierarchical clustering.
| Aspect | K-means | Hierarchical Clustering |
|---|---|---|
| K specified in advance | ? | ? |
| Result visualization | ? | ? |
| Time complexity | ? | ? |
| Sensitivity to outliers | ? | ? |
| Deterministic results | ? | ? |
Problem 7-4 ⭐⭐⭐ Scenario#
You want to segment customers using clustering. Variables: age (numeric), annual income (numeric), region (categorical: metropolitan/non-metropolitan), membership status (binary: Y/N)
(a) Identify which variables need scaling and explain why.
(b) Explain two ways to handle the categorical and binary variables.
(c) Among K-means, hierarchical clustering, and GMM, which is most appropriate for this situation and why?
Answers and Explanations#
Part 1 Answers#
1-1.
- Mean:
- Median: the 5th value after sorting =
- Mode: (appears 3 times)
1-2.
1-3. ✅ Answer: 2 — Median and IQR are robust statistics unaffected by outliers.
1-4. Output:
np.mean(data)→43.33...(the outlier 100 skews the mean)np.median(data)→40.0- IQR =
np.percentile(data, 75) - np.percentile(data, 25)=50 - 20=30.0
Part 2 Answers#
2-1. The distribution of the sample mean approaches a normal distribution, and the standard error is .
2-2.
(a) Standard error
(b) ,
2-3.
- Bootstrap: a resampling method that repeatedly draws new samples from the given sample with replacement to estimate the distribution of a statistic.
- Uses sampling with replacement (the same data point can be drawn multiple times).
- Useful when the sample size is small, the theoretical distribution of the statistic is unknown, or you need to estimate confidence intervals.
2-4.
(a) ,
(b)
Part 3 Answers#
3-1. ✅ Answer: 3 — The p-value is the probability of observing a result as extreme as (or more extreme than) the current one, assuming the null hypothesis is true.
3-2.
(a) : The new drug and the existing drug are equally effective ()
: The new drug is more effective ()
(b) One-tailed test — the question has a clear direction: "Is the new drug more effective?"
(c)
- Type I error (): Concluding the drug works when it actually doesn't → approving an ineffective drug
- Type II error (): Failing to detect a drug that actually works → missing a beneficial treatment
3-3. Use ANOVA (Analysis of Variance). Null hypothesis: (the conversion rates of all three channels are equal). If the F-statistic is significant, run a post-hoc test (e.g., Tukey HSD) to identify which specific pairs differ.
3-4. A/B testing exposes users equally to both versions during the exploration period, causing opportunity loss from the inferior version. MAB dynamically adjusts exposure based on performance to minimize that loss. A/B testing is better suited for: clinical drug trials requiring rigorous statistical inference. MAB is better suited for: real-time ad optimization, Netflix content recommendations.
Part 4 Answers#
4-1.
(a) A 1-unit increase in AdSpend is associated with an average increase of 2.345 in Sales (holding other variables constant).
(b) The model explains 78.2% of the variation in Sales ().
(c) Each additional unit of Age is associated with an average decrease of 0.430 in Sales (older means worse performance).
(d) None — all variables have p-values below 0.05 and are statistically significant.
4-2.
- RMSE: Average magnitude of prediction error (same units as the response variable)
- : Proportion of variance in the response explained by the model (0–1; closer to 1 is better)
- Confidence Interval: Range of uncertainty for the population mean response
- Prediction Interval: Range of uncertainty for a new individual observation
The prediction interval is wider — it captures both the uncertainty in the mean and the additional variability of an individual data point ().
4-3.
(a)
(b)
(c)
4-4.
- Situation A: Heteroscedasticity — error variance is not constant → apply log transformation or weighted regression
- Situation B: Non-normal residuals — normality assumption violated → consider variable transformation or robust regression
- Situation C: Influential point — high leverage, large residual → check for data errors, then remove or apply robust regression
Part 5 Answers#
5-1.
5-2.
(a) Odds = (ratio of an event occurring vs. not occurring for a single observation). Odds ratio = the ratio of two odds (the multiplicative change in odds per unit increase in a variable).
(b) → A 1-unit increase in increases the odds of the event occurring by approximately 65%.
(c) The probability is bounded to , while a linear combination ranges over all real numbers. The logit is a link function that maps to the entire real line.
5-3.
| Aspect | Naive Bayes | Logistic Regression |
|---|---|---|
| Probability estimation | Generative model (estimates P(X|C)) | Discriminative model (directly estimates P(C|X)) |
| Key assumption | Conditional independence of features | Logit is a linear combination of features |
| Advantages | Fast, works well with small datasets | Excellent probability calibration, handles multicollinearity |
| Disadvantages | Independence assumption rarely holds in practice | Requires more data, sensitive to feature scaling |
5-4.
(a) 97% (the proportion of negatives) — always predicting negative yields 0.97 accuracy.
(b) Because the model fails to detect any of the actual positives (cancer cases). Use Recall (Sensitivity), AUC, and F1 instead.
(c) Type I error is more serious — classifying a cancer patient as negative means they miss treatment, which is life-threatening. A Type II error (classifying a healthy person as positive) can be resolved with further testing.
(d) ① SMOTE (synthetic oversampling) ② Class weight adjustment (class_weight='balanced') ③ Lowering the classification threshold (to improve recall)
Part 6 Answers#
6-1.
(a) : Over-reliance on a single neighbor → overfitting, sensitive to noise. : All data points are neighbors → always predicts the majority class → underfitting.
(b) If income (in dollars) and age (in years) are used together without scaling, income dominates the distance metric. Standardization ensures each feature contributes equally.
(c) In text, the direction of word distribution matters more than document length for measuring similarity. Cosine distance measures direction (angle), not magnitude.
6-2.
(a) The model has memorized the training data perfectly — this is overfitting.
(b) ① Limit max_depth ② Increase min_samples_leaf ③ Apply pruning ④ Switch to Random Forest
(c) A single decision tree has very high variance (it is sensitive to changes in the data). Random Forest averages many trees to reduce variance. Bias remains similar, but the large reduction in variance significantly improves generalization.
6-3.
| Aspect | Bagging | Boosting |
|---|---|---|
| Training order | Parallel (independent) | Sequential (each corrects prior errors) |
| Error primarily reduced | Variance | Bias |
| Sensitivity to outliers | Low | High (misclassified points get higher weight) |
| Representative algorithm | Random Forest | XGBoost, LightGBM, AdaBoost |
6-4.
- Situation A (Overfitting): Decrease
learning_rate, reducemax_depth, addsubsample, reducen_estimators, add regularization () - Situation B (Underfitting): Increase
n_estimators, raiselearning_rate, increasemax_depth - Situation C (Speed issue): Switch to LightGBM, reduce
n_estimators, reduce feature count (PCA), apply early stopping
Part 7 Answers#
7-1. ✅ Answer: 3 — Standardization before PCA is required. Features with a larger scale will dominate the principal components.
7-2.
(a) Euclidean distances:
| Point | Assignment | ||
|---|---|---|---|
| A(1,1) | 0 | Cluster 1 | |
| B(2,1) | 1 | Cluster 1 | |
| C(4,3) | Cluster 2 | ||
| D(5,4) | 0 | Cluster 2 | |
| E(3,2) | Cluster 1 |
(b) New centroids:
7-3.
| Aspect | K-means | Hierarchical Clustering |
|---|---|---|
| K specified in advance | Required | Not required (decided post-hoc) |
| Result visualization | Scatter plot | Dendrogram |
| Time complexity | — fast | — slow |
| Sensitivity to outliers | Distorts centroids | Sensitive with single linkage |
| Deterministic results | No (depends on initialization) | Yes (fixed by distance metric) |
7-4.
(a) Age and annual income — the difference in scale distorts distance calculations. Apply standardization or MinMax scaling.
(b) ① One-hot encode, then standardize. ② Use Gower Distance — it handles a mix of numeric, categorical, and binary variables by computing a unified [0,1] similarity score.
(c) Gower distance-based hierarchical clustering or GMM is recommended. K-means only supports Euclidean distance, making it awkward with categorical data. If the number of customers is not too large, hierarchical clustering lets you inspect the dendrogram and choose K intuitively.
Grading Rubric#
| Part | Points | Content |
|---|---|---|
| Part 1 (Ch. 1) | 20 pts | Descriptive statistics concepts and calculation |
| Part 2 (Ch. 2) | 20 pts | Sampling distributions, bootstrap, probability distributions |
| Part 3 (Ch. 3) | 15 pts | Hypothesis testing, p-values, A/B testing |
| Part 4 (Ch. 4) | 20 pts | Regression coefficient interpretation, residual diagnostics |
| Part 5 (Ch. 5) | 20 pts | Classification, confusion matrix, class imbalance |
| Part 6 (Ch. 6) | 15 pts | KNN, decision trees, ensemble methods |
| Part 7 (Ch. 7) | 15 pts | PCA, clustering |
| Total | 125 pts |
90 or above: Ready for real-world work — core data science fundamentals mastered
70–89: Good conceptual understanding — focus on reviewing weaker sections
Below 70: Re-read the relevant chapters and try again
// Related Posts
Statistics Fundamentals Chapter 7: Unsupervised Learning
A hands-on overview of unsupervised learning essentials — PCA, K-Means, hierarchical clustering, Gaussian Mixture Models, and feature scaling — all with code examples.
Statistics Fundamentals Chapter 6: Statistical Machine Learning
A hands-on walkthrough of KNN, decision trees, random forests, AdaBoost, and gradient boosting — the core concepts behind tree-based ensemble models, complete with code examples.
Statistics Fundamentals Chapter 5: Classification
A hands-on guide to classification algorithms — covering Naive Bayes, discriminant analysis, logistic regression, confusion matrices, ROC/AUC, and techniques for handling imbalanced data, all with code examples.