This final project consolidates the entire Statistics and Probability course into a single, submittable analysis report on the clinical-trial dataset, integrating the descriptive, inferential, and estimation work from the preceding capstone lessons into one coherent, professional deliverable. The project exists as the culminating demonstration that you can take a raw multi-variable dataset and produce a complete, rigorous, decision-ready analysis — the core competency of applied statistics. You will assemble a structured report that describes the data, characterises its distributions, tests the regime's effects with assumption checks and effect sizes, estimates those effects with confidence intervals, and delivers a clear, honest recommendation. The result is a portfolio-quality artifact proving you can wield the full statistical toolkit on a realistic problem from start to finish.
Learning Objectives
- Integrate descriptive statistics, distribution fitting, hypothesis testing, and confidence intervals into one coherent analysis.
- Select and justify the appropriate statistical method for each question and data type.
- Verify assumptions before every test and report effect sizes alongside significance.
- Attach confidence intervals to every key estimate, communicating uncertainty honestly.
- Distinguish statistical significance from practical importance in the conclusions.
- Produce a clear, structured, reproducible report culminating in a defensible recommendation.
Technical Requirements
- Load and validate the clinical-trial dataset, inspecting types and missing values.
- Produce group-wise descriptive summaries with central tendency, spread, and shape.
- Fit and validate the distribution of the skewed fitness variable with a goodness-of-fit test.
- Run a paired test, a two-group test, and a chi-square test, each preceded by an assumption check.
- Report Cohen's d or an equivalent effect size for every comparison.
- Construct confidence intervals for the treatment effect, injury-rate difference, and fitness median via bootstrap.
- Perform a power check, then conclude with a recommendation distinguishing statistical from practical significance.
Architecture & Design
The report is structured as a pipeline of stages that mirror the analytical arc: a data-loading and validation stage, a descriptive and distributional stage, an inferential stage with assumption checks and effect sizes, an estimation stage with confidence intervals, and a conclusion stage with the recommendation. This architecture exists because a professional analysis must be both logically ordered and reproducible, with each stage building on the verified outputs of the previous one and every decision documented. The design separates computation from reporting, computing all results first and then assembling them into a readable narrative, which mirrors how real analytical reports are produced. The data flows from raw CSV through description, inference, and estimation into a final structured summary, with each stage's findings informing the methods of the next, and the whole pipeline is reproducible from the dataset and the seed.
# capstone_report.py - architecture skeleton
import numpy as np
import pandas as pd
from scipy import stats
class CapstoneAnalysis:
"""End-to-end statistical analysis pipeline for the cricket trial."""
def __init__(self, csv_path, seed=42):
self.df = pd.read_csv(csv_path)
self.rng = np.random.default_rng(seed)
self.results = {}
def stage_1_load_validate(self): ... # types, missing values, shape
def stage_2_descriptive(self): ... # group summaries, shape, fitting
def stage_3_inference(self): ... # assumption checks, tests, effect sizes
def stage_4_estimation(self): ... # confidence intervals, bootstrap
def stage_5_conclude(self): ... # recommendation, sig vs practical
def run(self):
self.stage_1_load_validate()
self.stage_2_descriptive()
self.stage_3_inference()
self.stage_4_estimation()
return self.stage_5_conclude()
if __name__ == "__main__":
report = CapstoneAnalysis("cricket_trial.csv").run()
Phase 1 — Core Implementation
Phase 1 implements the loading, descriptive, and inferential stages, producing the validated data summary and the assumption-checked test results with effect sizes. This phase builds the analytical substance of the report — the description that frames the data and the tests that answer whether the regime works — drawing directly on the descriptive and inferential capstone lessons. It is the core because these stages produce the findings the estimation and conclusion will quantify and communicate.
# capstone_report.py - core stages
def stage_2_descriptive(self):
df = self.df
df["improvement"] = df["strike_after"] - df["strike_before"]
summary = {}
for grp, sub in df.groupby("group")["improvement"]:
summary[grp] = {"mean": sub.mean(), "median": sub.median(),
"std": sub.std(ddof=1)}
# Fit fitness distribution
best_p = {n: stats.kstest(df["fitness"], n, args=getattr(stats, n).fit(df["fitness"]))[1]
for n in ["norm", "gamma", "lognorm"]}
self.results["descriptive"] = summary
self.results["fitness_dist"] = max(best_p, key=best_p.get)
def stage_3_inference(self):
df = self.df
t = df[df.group == "treatment"]["improvement"].values
c = df[df.group == "control"]["improvement"].values
pooled = np.sqrt((t.var(ddof=1) + c.var(ddof=1)) / 2)
self.results["effect"] = {
"p_value": stats.ttest_ind(t, c, equal_var=False)[1],
"cohens_d": (t.mean() - c.mean()) / pooled,
}
Phase 2 — Feature Completion
Phase 2 implements the estimation stage and the conclusion, adding confidence intervals for the key metrics and assembling the final recommendation that distinguishes statistical from practical significance. This phase completes the analytical content by quantifying the uncertainty around the findings and translating them into an actionable verdict, drawing on the confidence-interval capstone lesson. It is what turns a set of test results into a decision-ready report.
# capstone_report.py - estimation and conclusion
def stage_4_estimation(self):
df = self.df
t = df[df.group == "treatment"]["improvement"].values
c = df[df.group == "control"]["improvement"].values
diff = t.mean() - c.mean()
se = np.sqrt(t.var(ddof=1)/len(t) + c.var(ddof=1)/len(c))
tc = stats.t.ppf(0.975, df=len(t)+len(c)-2)
self.results["effect_ci"] = (diff - tc*se, diff + tc*se)
def stage_5_conclude(self):
eff = self.results["effect"]
lo, hi = self.results["effect_ci"]
sig = eff["p_value"] < 0.05
meaningful = abs(eff["cohens_d"]) >= 0.5
if sig and meaningful:
rec = (f"Adopt the regime: effect is significant (p={eff['p_value']:.4g}), "
f"meaningful (d={eff['cohens_d']:.2f}), plausibly +{lo:.1f} to +{hi:.1f}.")
elif sig:
rec = "Significant but small effect; weigh cost before adopting."
else:
rec = "No significant effect detected; do not adopt on current evidence."
self.results["recommendation"] = rec
return self.results
Phase 3 — Polish & Production Readiness
Phase 3 adds the polish that makes the report production-ready: robust handling of edge cases like missing data, clear formatted output of every finding, and a reproducibility guarantee through the fixed seed. This phase exists because a professional deliverable must be robust and reproducible, not merely correct on one run, and the difference between a script that works once and a report that withstands scrutiny lies in this hardening. You will add validation, format the results into a readable report, and ensure anyone can reproduce your exact findings from the dataset and seed.
# capstone_report.py - production hardening
def stage_1_load_validate(self):
df = self.df
assert not df.isnull().any().any(), "Dataset contains missing values"
assert set(df["group"].unique()) == {"treatment", "control"}, "Bad group labels"
self.results["n"] = len(df)
self.results["groups"] = df["group"].value_counts().to_dict()
def format_report(self):
"""Produce the readable final report from computed results."""
r = self.results
lines = [
"=" * 55, "CRICKET TRAINING REGIME — STATISTICAL ANALYSIS", "=" * 55,
f"Sample: {r['n']} players {r['groups']}",
f"Fitness distribution: {r['fitness_dist']}",
f"Treatment effect: p={r['effect']['p_value']:.4g}, "
f"d={r['effect']['cohens_d']:.2f}",
f"95% CI for effect: [{r['effect_ci'][0]:.1f}, {r['effect_ci'][1]:.1f}]",
"-" * 55, f"RECOMMENDATION: {r['recommendation']}", "=" * 55,
]
return "\n".join(lines)
# Reproducible: same seed -> identical results every run
Evaluation Rubric
- Completeness: all five stages present — loading, descriptive, inference, estimation, conclusion.
- Correctness: appropriate method chosen for each question and data type, recovering the dataset's known effects.
- Rigour: assumptions checked before every test, effect sizes reported, power verified.
- Uncertainty: confidence intervals attached to every key estimate, with bootstrap used for the skewed median.
- Interpretation: p-values stated in the correct direction, statistical versus practical significance distinguished.
- Communication: report is clearly structured, readable, and culminates in a defensible recommendation.
- Reproducibility: analysis runs end to end from the dataset and seed, producing identical results each time.
Extension Challenges: Strengthen the capstone by adding a robustness section that re-runs every test non-parametrically and confirms the conclusions hold, demonstrating the findings do not depend on distributional assumptions. Add a subgroup analysis examining whether the regime's effect differs by player role, using appropriate corrections for the extra comparisons. Finally, produce a visual appendix with grouped boxplots, the fitted fitness distribution, and a forest-plot-style display of every confidence interval, turning the numeric report into a publication-quality document a senior reviewer would commend.