{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f9cb62b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "              abaudit — Experiment Validity Report              \n",
      "┌──────────────────────────────────┬──────────────────┬────────┐\n",
      "│ Check                           │ Result          │ Status │\n",
      "├──────────────────────────────────┼──────────────────┼────────┤\n",
      "│ p-value (primary)               │ 0.0000          │ ✅      │\n",
      "│ p-value (Bonferroni corrected)  │ 0.0000          │ ✅      │\n",
      "│ PPV — prob. effect is real      │ 0.83            │ ✅      │\n",
      "│ Statistical power               │ 0.99            │ ✅      │\n",
      "│ Sample Ratio Mismatch           │ p = 1.000       │ ✅      │\n",
      "│ Metrics tested                  │ 2               │ ⚠️     │\n",
      "│ Optional stopping (peeks)       │ eff. α = 0.226  │ ⚠️     │\n",
      "│ Effect size (Cohen's d)         │ 0.271           │ ✅      │\n",
      "└──────────────────────────────────┴──────────────────┴────────┘\n",
      "\n",
      "Bias score: [███░░░░░░░░░░░░░░░░░] 0.15 / 1.0  🟢 Low concern\n",
      "\n",
      "⚠️  Warnings:\n",
      "   • 2 metrics tested — Bonferroni-corrected p = 0.0000 (raw p = 0.0000).\n",
      "   • Optional stopping risk: p-value checked 5 times. Effective α ≈ 0.226 (nominal: 0.05).\n",
      "\n",
      "💡 Recommendations:\n",
      "   • Use sequential testing (SPRT) or an alpha-spending function when interim looks are necessary.\n",
      "\n",
      "✓ Report saved: d:\\GitHub\\abaudit\\audit_report.html\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'d:\\\\GitHub\\\\abaudit\\\\audit_report.html'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import abaudit as ab\n",
    "\n",
    "rng  = np.random.default_rng(42)\n",
    "ctrl = rng.normal(0, 1, 500)\n",
    "trt  = rng.normal(0.3, 1, 500)\n",
    "\n",
    "# During-experiment checks\n",
    "ab.check_srm(n_control=490, n_treatment=510)\n",
    "ab.check_optional_stopping([0.12, 0.08, 0.04, 0.06, 0.03])\n",
    "\n",
    "# Full audit + HTML report\n",
    "result = ab.audit(ctrl, trt, prior_f=0.2,\n",
    "                  metrics=[\"conversion\", \"revenue\"],\n",
    "                  n_peeks=5)\n",
    "result.summary()\n",
    "ab.generate_report(result, \"audit_report.html\")\n",
    "# open audit_report.html in your browser"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "355fef58",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv (3.11.0)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
