Analytical & Methodological Audit Dossier
Mathematical proofs, variance identities, direct standardization formulas, statistical test specifications, and full code traceability for the Khatabook Growth Platform.
1. Mathematical Proofs & Variance Identities
Proof 1.1: Exact Three-Factor Efficiency Decomposition
Cost per Approved Conversion is expressed as the product of three distinct commercial levers:
Let \(C_0\) be baseline unit cost (Campaign 936, $15.811) and \(C_1\) be scaled unit cost (Campaign 1178, $63.833). Under sequential substitution:
Validated in unit test tests/test_diagnostics.py::test_decomposition_bridge_mathematical_identity.
Proof 1.2: Direct Standardization & Confounding Adjustment
To adjust for demographic composition, we compute the pooled benchmark click distribution across all 4 age categories:
Validated in unit test tests/test_diagnostics.py::test_mix_adjustment_direct_standardization.
Proof 1.3: Two-Proportion Hypothesis Testing & Normal Approximation
For test evaluation under null hypothesis \(H_0: p_1 = p_2\):
Validated in unit test tests/test_statistics.py::test_two_proportion_z_test_calculation.
2. Code, Metric & File Traceability Matrix
| Analytical Dimension | Python Source | SQL Transform | Export File | Verification Test |
|---|---|---|---|---|
| Ratio-of-Sums Scorecard | src/metrics.py | sql/03_metrics.sql | exports/campaign_scorecard.csv | tests/test_metrics.py |
| Efficiency Waterfall | src/diagnostics.py | sql/03_metrics.sql | reports/campaign_diagnostic.md | tests/test_diagnostics.py |
| 4-Stage Funnel Drop-off | src/diagnostics.py | sql/06_funnel.sql | exports/funnel_analysis.csv | tests/test_funnel.py |
| Segment Stability (≥10, 25, 50) | src/diagnostics.py | sql/04_audience.sql | exports/segment_stability.csv | tests/test_diagnostics.py |
| Direct Standardization | src/diagnostics.py | sql/05_mix_analysis.sql | exports/mix_analysis.csv | tests/test_diagnostics.py |
| A/B Testing & Sample Sizing | src/statistics.py | — | Embedded in REST API | tests/test_statistics.py |
| 11-Rule Quality Audit | src/validation.py | sql/07_quality.sql | exports/data_quality.csv | tests/test_quality.py |
| Consumer Session Intent | src/data_loader.py | sql/02_clean.sql | exports/consumer_behavior.csv | tests/test_metrics.py |
| FastAPI REST Endpoints | backend/main.py | — | OpenAPI Swagger /docs | tests/test_backend.py |