An open API service indexing awesome lists of open source software.

https://github.com/ibrahimasifali94/sql_ab_test_metrics

SQL A/B test metrics with DuckDB – CTR, lift, p-value, and retention
https://github.com/ibrahimasifali94/sql_ab_test_metrics

ab-testing analytics duckdb sql

Last synced: about 1 month ago
JSON representation

SQL A/B test metrics with DuckDB – CTR, lift, p-value, and retention

Awesome Lists containing this project

README

          

# SQL A/B Test Metrics

**TL;DR:** DuckDB SQL to compute CTR lift, daily CTR, and D1 retention for a synthetic A/B test — with a z-test and p-value.

## What’s inside
- Problem: Measure whether variant **B** improves click-through rate (CTR) vs **A** and impact on D1 retention.
- Approach: Pure SQL over CSVs (DuckDB). Includes sanity checks, lift calc, and a two-sided z-test.
- Data: Synthetic CSVs in `data/` (generated by `generate_data.py`).
- Result: On this seed, B shows 1.30% absolute lift (28.14% relative lift) with a p-value of 0.039 (statistically significant)

## How to run
```bash
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python generate_data.py # optional if you want fresh data
duckdb -c ".read queries.sql"