Click the green "Use this template" button at the top of the page, then choose "Create a new repository".
This will create your own copy of this project, which you can modify freely — no need to fork!
Your first hands-on lab in designing, simulating, and analyzing A/B tests for causal inference.
Table of Contents
This project is a comprehensive walkthrough designed for:
- Data scientists starting their journey in A/B testing
- Students learning causal inference through simulation
- Professionals who want a clean, well-explained portfolio project
You'll simulate online experiments, perform statistical tests (manually and via scipy
), visualize results with confidence intervals, and explore how low power affects false positives. This lab is both a learning tool and a public showcase for your GitHub portfolio.
- How to simulate binary outcome data (e.g. conversion)
- Run hypothesis tests: manual Z-test and
scipy
t-test - Calculate and visualize confidence intervals
- Understand p-values, alpha levels, and Type I/II errors
- Simulate and explore the False Positive Risk (FPR)
- Visualize “what if” scenarios: low power, small effects, bad design
AB-Testing_Causal-Inference-Starter/
├── notebooks/
│ └── 01_ab_test_simulation.ipynb # Main walkthrough notebook
├── data/
│ └── synthetic_ab_test.csv # Simulated experiment dataset
├── scripts/
│ └── abtest_utils.py # Reusable functions
├── images/
│ └── pvalue_distribution.png # Visual outputs for README/docs
├── README.md # Project overview (you are here)
└── LICENSE # MIT License
git clone https://github.com/your-username/AB-Testing_Causal-Inference-Starter.git
cd AB-Testing_Causal-Inference-Starter
pip install numpy pandas matplotlib scipy jupyter
jupyter notebook notebooks/01_ab_test_simulation.ipynb
- Conversion rates (e.g. 10% vs 11%)
- Generate binary data for 10,000 users each group
- Pooled standard error
- Z-statistic
- Manual p-value calculation
scipy.stats.ttest_ind
or z-proportion test- Compare with manual results
- Bar plots with error bars
- Bootstrap sampling distributions
- Run 1000 null experiments
- Show that ~5% are “significant” by chance
- Explore what happens when power is low
- Low sample size vs. high MDE
- Winner’s curse demonstration
- Sign vs magnitude errors
Each notebook section includes:
- 👩🏫 Teaching comments and annotated code
- 📌 Real-world context from online experimentation
- 💡 Insights from industry practice (Expedia, Microsoft, Airbnb)
See the /images
folder for example outputs:
- p-value distributions
- confidence interval charts
- bootstrap effect distributions
- Python 3.8+
numpy
,pandas
,scipy
,matplotlib
- Jupyter Notebook
This project is licensed under the MIT License - see the LICENSE file for details.
- Trustworthy Online Controlled Experiments by Ron Kohavi et al.
- "False Positives in A/B Tests" (KDD '24)
- Andrew Gelman & John Carlin on sign and magnitude errors
If you’re a recruiter, data science student, or just excited about experimentation, feel free to reach out or star this repo!
Let’s learn causal inference—one experiment at a time. 🌱