Publish overlift interface
Browse files- README.md +18 -5
- data.json +0 -0
- index.html +484 -17
README.md
CHANGED
|
@@ -1,10 +1,23 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: overlift
|
| 3 |
+
emoji: 📉
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: gray
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
short_description: The winner of your A/B test is not as good as it looked
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# overlift
|
| 13 |
+
|
| 14 |
+
The winner's curse, peeking and power, measured on **32,363 real randomised
|
| 15 |
+
experiments** from the [Upworthy Research Archive](https://osf.io/jd64p/)
|
| 16 |
+
(Matias, Munger, Le Quere & Ebersole, CC BY 4.0).
|
| 17 |
+
|
| 18 |
+
Every arm's impressions are dealt at random into a selection half and a held-out
|
| 19 |
+
half: pick the best arm on one, score it on the other. Nothing is simulated —
|
| 20 |
+
the clicks are the archive's clicks. The page re-runs that split in your browser,
|
| 21 |
+
so "re-split the traffic" really does re-deal the impressions.
|
| 22 |
+
|
| 23 |
+
Code, method and the full write-up: <https://github.com/UsmarHaider/overlift>
|
data.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
index.html
CHANGED
|
@@ -1,19 +1,486 @@
|
|
| 1 |
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
<!doctype html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="utf-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>overlift — the winner of your A/B test is not that good</title>
|
| 7 |
+
<meta name="description" content="32,363 real randomised experiments from the Upworthy Research Archive, re-split to show how much of a winner's lift is noise.">
|
| 8 |
+
<style>
|
| 9 |
+
:root {
|
| 10 |
+
--surface: #fcfcfb;
|
| 11 |
+
--plane: #f4f3ef;
|
| 12 |
+
--card: #ffffff;
|
| 13 |
+
--ink: #0b0b0b;
|
| 14 |
+
--ink2: #52514e;
|
| 15 |
+
--muted: #898781;
|
| 16 |
+
--grid: #e1e0d9;
|
| 17 |
+
--axis: #c3c2b7;
|
| 18 |
+
--blue: #2a78d6;
|
| 19 |
+
--orange: #eb6834;
|
| 20 |
+
--aqua: #1baf7a;
|
| 21 |
+
--yellow: #a8730a;
|
| 22 |
+
--shadow: 0 1px 2px rgba(11,11,11,.06), 0 8px 24px rgba(11,11,11,.05);
|
| 23 |
+
}
|
| 24 |
+
@media (prefers-color-scheme: dark) {
|
| 25 |
+
:root {
|
| 26 |
+
--surface: #1a1a19;
|
| 27 |
+
--plane: #121211;
|
| 28 |
+
--card: #232322;
|
| 29 |
+
--ink: #ffffff;
|
| 30 |
+
--ink2: #c3c2b7;
|
| 31 |
+
--muted: #898781;
|
| 32 |
+
--grid: #2c2c2a;
|
| 33 |
+
--axis: #383835;
|
| 34 |
+
--blue: #3987e5;
|
| 35 |
+
--orange: #d95926;
|
| 36 |
+
--aqua: #199e70;
|
| 37 |
+
--yellow: #c98500;
|
| 38 |
+
--shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
* { box-sizing: border-box; }
|
| 42 |
+
body {
|
| 43 |
+
margin: 0;
|
| 44 |
+
background: var(--plane);
|
| 45 |
+
color: var(--ink);
|
| 46 |
+
font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
| 47 |
+
-webkit-font-smoothing: antialiased;
|
| 48 |
+
}
|
| 49 |
+
.wrap { max-width: 1060px; margin: 0 auto; padding: 34px 20px 60px; }
|
| 50 |
+
header { margin-bottom: 26px; }
|
| 51 |
+
h1 {
|
| 52 |
+
font-size: 30px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.02em;
|
| 53 |
+
}
|
| 54 |
+
h1 .dot { color: var(--orange); }
|
| 55 |
+
.lede { color: var(--ink2); margin: 0; max-width: 66ch; }
|
| 56 |
+
.lede b { color: var(--ink); font-weight: 600; }
|
| 57 |
+
h2 { font-size: 15px; margin: 0 0 4px; letter-spacing: -0.01em; }
|
| 58 |
+
.sub { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
|
| 59 |
+
|
| 60 |
+
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 22px 0 26px; }
|
| 61 |
+
.tile {
|
| 62 |
+
background: var(--card); border: 1px solid var(--grid); border-radius: 12px;
|
| 63 |
+
padding: 14px 15px; box-shadow: var(--shadow);
|
| 64 |
+
}
|
| 65 |
+
.tile .k { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
|
| 66 |
+
.tile .k.warn { color: var(--orange); }
|
| 67 |
+
.tile .k.good { color: var(--blue); }
|
| 68 |
+
.tile .t { font-size: 12px; color: var(--ink2); margin-top: 5px; }
|
| 69 |
+
|
| 70 |
+
.card {
|
| 71 |
+
background: var(--card); border: 1px solid var(--grid); border-radius: 14px;
|
| 72 |
+
padding: 18px 20px 20px; box-shadow: var(--shadow); margin-bottom: 18px;
|
| 73 |
+
}
|
| 74 |
+
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
|
| 75 |
+
button {
|
| 76 |
+
font: inherit; font-size: 13.5px; font-weight: 550; color: #fff; background: var(--blue);
|
| 77 |
+
border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer;
|
| 78 |
+
}
|
| 79 |
+
button:hover { filter: brightness(1.07); }
|
| 80 |
+
button.ghost { background: transparent; color: var(--ink2); border: 1px solid var(--axis); }
|
| 81 |
+
button:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
|
| 82 |
+
.pill {
|
| 83 |
+
font-size: 12px; color: var(--ink2); background: var(--plane);
|
| 84 |
+
border: 1px solid var(--grid); border-radius: 999px; padding: 4px 10px;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
| 88 |
+
th {
|
| 89 |
+
text-align: right; font-weight: 550; color: var(--muted); font-size: 11.5px;
|
| 90 |
+
text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 7px; white-space: nowrap;
|
| 91 |
+
}
|
| 92 |
+
th:first-child, td:first-child { text-align: left; }
|
| 93 |
+
td { padding: 8px; border-top: 1px solid var(--grid); text-align: right; vertical-align: top; }
|
| 94 |
+
td.head { color: var(--ink); max-width: 380px; }
|
| 95 |
+
tr.win td { background: color-mix(in srgb, var(--blue) 9%, transparent); }
|
| 96 |
+
tr.win td.head::before {
|
| 97 |
+
content: "picked"; display: inline-block; font-size: 10px; font-weight: 650;
|
| 98 |
+
letter-spacing: .05em; text-transform: uppercase; color: #fff; background: var(--blue);
|
| 99 |
+
border-radius: 4px; padding: 1px 5px; margin-right: 7px; vertical-align: 1px;
|
| 100 |
+
}
|
| 101 |
+
.bar { height: 4px; border-radius: 2px; background: var(--axis); margin-top: 5px; }
|
| 102 |
+
.num { font-variant-numeric: tabular-nums; }
|
| 103 |
+
|
| 104 |
+
.verdict { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-end; margin: 16px 0 4px; }
|
| 105 |
+
.metric .v { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
|
| 106 |
+
.metric .l { font-size: 11.5px; color: var(--muted); }
|
| 107 |
+
.badge {
|
| 108 |
+
margin-left: auto; font-size: 12.5px; font-weight: 600; border-radius: 8px;
|
| 109 |
+
padding: 6px 11px; border: 1px solid;
|
| 110 |
+
}
|
| 111 |
+
.badge.held { color: var(--blue); border-color: var(--blue); background: color-mix(in srgb, var(--blue) 10%, transparent); }
|
| 112 |
+
.badge.gone { color: var(--orange); border-color: var(--orange); background: color-mix(in srgb, var(--orange) 10%, transparent); }
|
| 113 |
+
|
| 114 |
+
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
|
| 115 |
+
figure { margin: 0; }
|
| 116 |
+
figcaption { font-size: 12px; color: var(--muted); margin-top: 8px; }
|
| 117 |
+
svg { display: block; width: 100%; height: auto; overflow: visible; }
|
| 118 |
+
.axis-t { font-size: 10px; fill: var(--muted); }
|
| 119 |
+
.lbl { font-size: 11px; font-weight: 550; }
|
| 120 |
+
footer { color: var(--muted); font-size: 12px; margin-top: 26px; line-height: 1.7; }
|
| 121 |
+
footer a { color: var(--ink2); }
|
| 122 |
+
.scroller { overflow-x: auto; }
|
| 123 |
+
@media (max-width: 860px) {
|
| 124 |
+
.tiles { grid-template-columns: repeat(2, 1fr); }
|
| 125 |
+
.grid2 { grid-template-columns: 1fr; }
|
| 126 |
+
}
|
| 127 |
+
</style>
|
| 128 |
+
</head>
|
| 129 |
+
<body>
|
| 130 |
+
<div class="wrap">
|
| 131 |
+
<header>
|
| 132 |
+
<h1>overlift<span class="dot">.</span></h1>
|
| 133 |
+
<p class="lede">
|
| 134 |
+
<b>32,363 real randomised experiments</b> from the Upworthy Research Archive, re-split so the
|
| 135 |
+
arm you would have picked gets scored on traffic it never saw. Every number below is measured
|
| 136 |
+
on real clicks — no effects are simulated.
|
| 137 |
+
</p>
|
| 138 |
+
</header>
|
| 139 |
+
|
| 140 |
+
<div class="tiles" id="tiles"></div>
|
| 141 |
+
|
| 142 |
+
<section class="card">
|
| 143 |
+
<h2>Pick a winner, then check it against held-out traffic</h2>
|
| 144 |
+
<p class="sub">
|
| 145 |
+
Half of each arm's impressions choose the winner; the other half scores it. Re-split to see how
|
| 146 |
+
much of the verdict was the coin, not the copy.
|
| 147 |
+
</p>
|
| 148 |
+
<div class="row">
|
| 149 |
+
<button id="sample">Try a sample test</button>
|
| 150 |
+
<button id="resplit" class="ghost">Re-split the traffic</button>
|
| 151 |
+
<button id="next" class="ghost">Another test</button>
|
| 152 |
+
<span class="pill" id="meta">—</span>
|
| 153 |
+
</div>
|
| 154 |
+
<div class="scroller">
|
| 155 |
+
<table id="arms">
|
| 156 |
+
<thead>
|
| 157 |
+
<tr>
|
| 158 |
+
<th>Headline</th><th>Impressions</th><th>CTR</th>
|
| 159 |
+
<th>Selection half</th><th>Held-out half</th><th>Shrunk</th>
|
| 160 |
+
</tr>
|
| 161 |
+
</thead>
|
| 162 |
+
<tbody></tbody>
|
| 163 |
+
</table>
|
| 164 |
+
</div>
|
| 165 |
+
<div class="verdict">
|
| 166 |
+
<div class="metric"><div class="v" id="v-claim" style="color:var(--orange)">—</div><div class="l">lift you would have claimed</div></div>
|
| 167 |
+
<div class="metric"><div class="v" id="v-real" style="color:var(--blue)">—</div><div class="l">lift on held-out traffic</div></div>
|
| 168 |
+
<div class="metric"><div class="v" id="v-eb">—</div><div class="l">shrunk prediction</div></div>
|
| 169 |
+
<div class="metric"><div class="v" id="v-p">—</div><div class="l">p-value, winner vs rest</div></div>
|
| 170 |
+
<div class="badge" id="badge">—</div>
|
| 171 |
+
</div>
|
| 172 |
+
</section>
|
| 173 |
+
|
| 174 |
+
<section class="card">
|
| 175 |
+
<h2>What the dashboard would have shown you along the way</h2>
|
| 176 |
+
<p class="sub">
|
| 177 |
+
The z-statistic for the top two arms as traffic accumulates over ten looks. Inside the grey band
|
| 178 |
+
nothing is significant at 5%; the dashed line is the O'Brien-Fleming boundary that keeps ten
|
| 179 |
+
looks honest.
|
| 180 |
+
</p>
|
| 181 |
+
<figure>
|
| 182 |
+
<svg id="zpath" viewBox="0 0 720 240" role="img" aria-label="Sequential z-statistic across ten looks"></svg>
|
| 183 |
+
<figcaption id="zcap">—</figcaption>
|
| 184 |
+
</figure>
|
| 185 |
+
</section>
|
| 186 |
+
|
| 187 |
+
<div class="grid2">
|
| 188 |
+
<section class="card">
|
| 189 |
+
<h2>Peeking, on real A/A splits</h2>
|
| 190 |
+
<p class="sub">One arm dealt into two. True difference: exactly zero.</p>
|
| 191 |
+
<figure>
|
| 192 |
+
<svg id="c-peek" viewBox="0 0 420 210" role="img" aria-label="False positive rate against number of looks"></svg>
|
| 193 |
+
<figcaption>False positives when nothing is there.</figcaption>
|
| 194 |
+
</figure>
|
| 195 |
+
</section>
|
| 196 |
+
<section class="card">
|
| 197 |
+
<h2>Arms, on real null tests</h2>
|
| 198 |
+
<p class="sub">One arm dealt into k. Every arm identical.</p>
|
| 199 |
+
<figure>
|
| 200 |
+
<svg id="c-mult" viewBox="0 0 420 210" role="img" aria-label="False positive rate against number of arms"></svg>
|
| 201 |
+
<figcaption>A “significant” winner where none exists.</figcaption>
|
| 202 |
+
</figure>
|
| 203 |
+
</section>
|
| 204 |
+
</div>
|
| 205 |
+
|
| 206 |
+
<footer>
|
| 207 |
+
Data: <a href="https://osf.io/jd64p/">Upworthy Research Archive</a> (Matias, Munger, Le Quere &
|
| 208 |
+
Ebersole), CC BY 4.0 — headlines shown as published in the archive.<br>
|
| 209 |
+
Code and method: <a href="https://github.com/UsmarHaider/overlift">github.com/UsmarHaider/overlift</a>.
|
| 210 |
+
</footer>
|
| 211 |
+
</div>
|
| 212 |
+
|
| 213 |
+
<script>
|
| 214 |
+
"use strict";
|
| 215 |
+
|
| 216 |
+
const pct = (v, d = 0) => (v === null || v === undefined || !isFinite(v)) ? "—" : (v * 100).toFixed(d) + "%";
|
| 217 |
+
const num = (v) => v.toLocaleString("en-US");
|
| 218 |
+
|
| 219 |
+
// A seeded PRNG so "re-split" is reproducible from the URL, and an exact deal of
|
| 220 |
+
// c clicks into cells of the given sizes -- the same multivariate hypergeometric
|
| 221 |
+
// the Python pipeline uses, written out as sampling without replacement.
|
| 222 |
+
function mulberry32(a) {
|
| 223 |
+
return function () {
|
| 224 |
+
a |= 0; a = (a + 0x6D2B79F5) | 0;
|
| 225 |
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
| 226 |
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
| 227 |
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
| 228 |
+
};
|
| 229 |
+
}
|
| 230 |
+
function deal(n, c, sizes, rng) {
|
| 231 |
+
const out = new Array(sizes.length).fill(0);
|
| 232 |
+
let remainingTotal = n, remainingClicks = c;
|
| 233 |
+
const room = sizes.slice();
|
| 234 |
+
for (let i = 0; i < sizes.length - 1; i++) {
|
| 235 |
+
let got = 0;
|
| 236 |
+
let poolLeft = remainingTotal, cellLeft = room[i], clicks = remainingClicks;
|
| 237 |
+
// Deal the remaining clicks one at a time into "this cell" or "the rest".
|
| 238 |
+
for (let k = 0; k < clicks; k++) {
|
| 239 |
+
if (poolLeft <= 0) break;
|
| 240 |
+
if (rng() < cellLeft / poolLeft) { got++; cellLeft--; }
|
| 241 |
+
poolLeft--;
|
| 242 |
+
}
|
| 243 |
+
out[i] = got;
|
| 244 |
+
remainingClicks -= got;
|
| 245 |
+
remainingTotal -= sizes[i];
|
| 246 |
+
}
|
| 247 |
+
out[sizes.length - 1] = remainingClicks;
|
| 248 |
+
return out;
|
| 249 |
+
}
|
| 250 |
+
function equalSizes(n, m) {
|
| 251 |
+
const base = Math.floor(n / m), rem = n - base * m;
|
| 252 |
+
return Array.from({ length: m }, (_, i) => base + (i < rem ? 1 : 0));
|
| 253 |
+
}
|
| 254 |
+
function ctr(c, n) { return n > 0 ? c / n : 0; }
|
| 255 |
+
function zTest(c1, n1, c2, n2) {
|
| 256 |
+
const p1 = ctr(c1, n1), p2 = ctr(c2, n2), p = ctr(c1 + c2, n1 + n2);
|
| 257 |
+
const se = Math.sqrt(p * (1 - p) * (1 / n1 + 1 / n2));
|
| 258 |
+
return se > 0 ? (p1 - p2) / se : 0;
|
| 259 |
+
}
|
| 260 |
+
function normSf(z) { // Abramowitz & Stegun 7.1.26, plenty for a displayed p-value
|
| 261 |
+
const t = 1 / (1 + 0.2316419 * Math.abs(z));
|
| 262 |
+
const d = 0.3989422804014327 * Math.exp(-z * z / 2);
|
| 263 |
+
const p = d * t * (0.319381530 + t * (-0.356563782 + t * (1.781477937 + t * (-1.821255978 + t * 1.330274429))));
|
| 264 |
+
return z > 0 ? p : 1 - p;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
let DATA = null, INDEX = 0, SEED = 1;
|
| 268 |
+
|
| 269 |
+
async function boot() {
|
| 270 |
+
DATA = await (await fetch("data.json", { cache: "no-store" })).json();
|
| 271 |
+
const url = new URL(location.href);
|
| 272 |
+
INDEX = Math.max(0, Math.min(DATA.tests.length - 1, parseInt(url.searchParams.get("sample") ?? "6", 10) || 0));
|
| 273 |
+
renderTiles();
|
| 274 |
+
renderPeek();
|
| 275 |
+
renderMult();
|
| 276 |
+
render();
|
| 277 |
+
document.getElementById("sample").onclick = () => { INDEX = (INDEX + 7) % DATA.tests.length; SEED = 1; render(); };
|
| 278 |
+
document.getElementById("next").onclick = () => { INDEX = (INDEX + 1) % DATA.tests.length; SEED = 1; render(); };
|
| 279 |
+
document.getElementById("resplit").onclick = () => { SEED++; render(); };
|
| 280 |
+
// boot() already renders a fully populated state, so ?demo=1 only fixes the
|
| 281 |
+
// seed -- it exists so screenshots are reproducible.
|
| 282 |
+
if (url.searchParams.get("demo") === "1") { SEED = 1; render(); }
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
function renderTiles() {
|
| 286 |
+
const c = DATA.curse.vs_test_average, p = DATA.power;
|
| 287 |
+
const peek = DATA.peeking.aa_nulls.by_looks["10"];
|
| 288 |
+
const tiles = [
|
| 289 |
+
{ k: pct(c.median_in_sample), cls: "warn", t: "median lift the winning arm appears to have" },
|
| 290 |
+
{ k: pct(c.median_out_of_sample), cls: "good", t: "median lift it actually has on held-out traffic" },
|
| 291 |
+
{ k: pct(peek.naive), cls: "warn", t: "false positives from peeking 10 times at a null test" },
|
| 292 |
+
{ k: pct(p.median_mde_relative), cls: "", t: "smallest lift the median test could even detect" },
|
| 293 |
+
];
|
| 294 |
+
document.getElementById("tiles").innerHTML = tiles.map(t =>
|
| 295 |
+
`<div class="tile"><div class="k ${t.cls}">${t.k}</div><div class="t">${t.t}</div></div>`).join("");
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
function splitTest(t, seed) {
|
| 299 |
+
const rng = mulberry32(seed * 7919 + t.impressions);
|
| 300 |
+
const arms = t.arms.map(a => {
|
| 301 |
+
const nA = Math.round(a.impressions / 2);
|
| 302 |
+
const [cA, cB] = deal(a.impressions, a.clicks, [nA, a.impressions - nA], rng);
|
| 303 |
+
return { ...a, nA, cA, nB: a.impressions - nA, cB, sel: ctr(cA, nA), hold: ctr(cB, a.impressions - nA) };
|
| 304 |
+
});
|
| 305 |
+
const selC = arms.reduce((s, a) => s + a.cA, 0), selN = arms.reduce((s, a) => s + a.nA, 0);
|
| 306 |
+
const holC = arms.reduce((s, a) => s + a.cB, 0), holN = arms.reduce((s, a) => s + a.nB, 0);
|
| 307 |
+
const poolSel = ctr(selC, selN), poolHold = ctr(holC, holN);
|
| 308 |
+
let w = 0;
|
| 309 |
+
arms.forEach((a, i) => { if (a.sel > arms[w].sel) w = i; });
|
| 310 |
+
const kappa = DATA.curse.config.kappa;
|
| 311 |
+
arms.forEach(a => { a.eb = (a.cA + kappa * poolSel) / (a.nA + kappa); });
|
| 312 |
+
|
| 313 |
+
const restC = selC - arms[w].cA, restN = selN - arms[w].nA;
|
| 314 |
+
const z = zTest(arms[w].cA, arms[w].nA, restC, restN);
|
| 315 |
+
const bestHold = arms.reduce((b, a, i) => (a.hold > arms[b].hold ? i : b), 0);
|
| 316 |
+
|
| 317 |
+
const order = arms.map((a, i) => i).sort((x, y) => arms[y].sel - arms[x].sel);
|
| 318 |
+
const top = order[0], second = order[1] ?? order[0];
|
| 319 |
+
const looks = DATA.meta.looks;
|
| 320 |
+
const path = [];
|
| 321 |
+
const pair = [top, second].map(i => {
|
| 322 |
+
const sizes = equalSizes(t.arms[i].impressions, looks);
|
| 323 |
+
return { sizes, inc: deal(t.arms[i].impressions, t.arms[i].clicks, sizes, rng) };
|
| 324 |
+
});
|
| 325 |
+
let n1 = 0, c1 = 0, n2 = 0, c2 = 0;
|
| 326 |
+
for (let k = 0; k < looks; k++) {
|
| 327 |
+
n1 += pair[0].sizes[k]; c1 += pair[0].inc[k];
|
| 328 |
+
n2 += pair[1].sizes[k]; c2 += pair[1].inc[k];
|
| 329 |
+
path.push(zTest(c1, n1, c2, n2));
|
| 330 |
+
}
|
| 331 |
+
return {
|
| 332 |
+
arms, w, poolSel, poolHold, z, path,
|
| 333 |
+
p: 2 * normSf(Math.abs(z)),
|
| 334 |
+
liftSel: poolSel > 0 ? arms[w].sel / poolSel - 1 : null,
|
| 335 |
+
liftHold: poolHold > 0 ? arms[w].hold / poolHold - 1 : null,
|
| 336 |
+
ebLift: poolSel > 0 ? arms[w].eb / poolSel - 1 : null,
|
| 337 |
+
heldUp: bestHold === w,
|
| 338 |
+
};
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
function render() {
|
| 342 |
+
const t = DATA.tests[INDEX];
|
| 343 |
+
const s = splitTest(t, SEED);
|
| 344 |
+
const maxCtr = Math.max(...s.arms.map(a => a.ctr)) || 1;
|
| 345 |
+
|
| 346 |
+
document.getElementById("meta").textContent =
|
| 347 |
+
`${t.arms.length} arms · ${num(t.impressions)} impressions · varied the ${t.variation} · test ${INDEX + 1}/${DATA.tests.length}`;
|
| 348 |
+
|
| 349 |
+
document.querySelector("#arms tbody").innerHTML = s.arms.map((a, i) => `
|
| 350 |
+
<tr class="${i === s.w ? "win" : ""}">
|
| 351 |
+
<td class="head">${escapeHtml(a.headline || "(headline not recorded)")}
|
| 352 |
+
<div class="bar" style="width:${(a.ctr / maxCtr * 100).toFixed(1)}%;background:${i === s.w ? "var(--blue)" : "var(--axis)"}"></div>
|
| 353 |
+
</td>
|
| 354 |
+
<td class="num">${num(a.impressions)}</td>
|
| 355 |
+
<td class="num">${pct(a.ctr, 2)}</td>
|
| 356 |
+
<td class="num" style="color:var(--orange)">${pct(a.sel, 2)}</td>
|
| 357 |
+
<td class="num" style="color:var(--blue)">${pct(a.hold, 2)}</td>
|
| 358 |
+
<td class="num">${pct(a.eb, 2)}</td>
|
| 359 |
+
</tr>`).join("");
|
| 360 |
+
|
| 361 |
+
document.getElementById("v-claim").textContent = s.liftSel === null ? "—" : (s.liftSel >= 0 ? "+" : "") + pct(s.liftSel, 1);
|
| 362 |
+
document.getElementById("v-real").textContent = s.liftHold === null ? "—" : (s.liftHold >= 0 ? "+" : "") + pct(s.liftHold, 1);
|
| 363 |
+
document.getElementById("v-eb").textContent = s.ebLift === null ? "—" : (s.ebLift >= 0 ? "+" : "") + pct(s.ebLift, 1);
|
| 364 |
+
document.getElementById("v-p").textContent = s.p < 0.001 ? "<0.001" : s.p.toFixed(3);
|
| 365 |
+
|
| 366 |
+
const badge = document.getElementById("badge");
|
| 367 |
+
badge.className = "badge " + (s.heldUp ? "held" : "gone");
|
| 368 |
+
badge.textContent = s.heldUp ? "still the best arm on held-out traffic" : "a different arm wins on held-out traffic";
|
| 369 |
+
|
| 370 |
+
renderZ(s.path);
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
function escapeHtml(str) {
|
| 374 |
+
return str.replace(/[&<>"']/g, ch => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[ch]));
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
function renderZ(path) {
|
| 378 |
+
const svg = document.getElementById("zpath");
|
| 379 |
+
const W = 720, H = 240, L = 44, R = 16, T = 14, B = 30;
|
| 380 |
+
const obf = DATA.meta.obf_bounds;
|
| 381 |
+
// Zoom to the action: the O'Brien-Fleming boundary starts near z = 6 and would
|
| 382 |
+
// otherwise squash every real path into a flat line near the axis.
|
| 383 |
+
const lim = Math.min(5.2, Math.max(2.9, ...path.map(Math.abs)) * 1.2);
|
| 384 |
+
const x = i => L + (W - L - R) * (i / (path.length - 1));
|
| 385 |
+
const y = v => T + (H - T - B) * (1 - (v + lim) / (2 * lim));
|
| 386 |
+
const line = pts => pts.map((p, i) => (i ? "L" : "M") + p[0].toFixed(1) + " " + p[1].toFixed(1)).join(" ");
|
| 387 |
+
|
| 388 |
+
const zf = DATA.meta.z_fixed;
|
| 389 |
+
const cross = path.findIndex(v => Math.abs(v) >= zf);
|
| 390 |
+
const parts = [];
|
| 391 |
+
parts.push(`<rect x="${L}" y="${y(zf)}" width="${W - L - R}" height="${y(-zf) - y(zf)}" fill="var(--grid)" opacity=".55"/>`);
|
| 392 |
+
parts.push(`<line x1="${L}" x2="${W - R}" y1="${y(0)}" y2="${y(0)}" stroke="var(--axis)" stroke-width="1"/>`);
|
| 393 |
+
for (const sgn of [1, -1]) {
|
| 394 |
+
parts.push(`<path d="${line(obf.map((b, i) => [x(i), y(sgn * Math.min(b, lim))]))}" fill="none"
|
| 395 |
+
stroke="var(--muted)" stroke-width="1.4" stroke-dasharray="4 4"/>`);
|
| 396 |
+
}
|
| 397 |
+
parts.push(`<path d="${line(path.map((v, i) => [x(i), y(v)]))}" fill="none" stroke="var(--blue)" stroke-width="2.4" stroke-linejoin="round"/>`);
|
| 398 |
+
path.forEach((v, i) => {
|
| 399 |
+
const hit = Math.abs(v) >= zf;
|
| 400 |
+
parts.push(`<circle cx="${x(i)}" cy="${y(v)}" r="${hit ? 5 : 3.6}" fill="${hit ? "var(--orange)" : "var(--blue)"}"
|
| 401 |
+
stroke="var(--card)" stroke-width="1.6"><title>look ${i + 1}: z = ${v.toFixed(2)}</title></circle>`);
|
| 402 |
+
parts.push(`<text class="axis-t" x="${x(i)}" y="${H - 10}" text-anchor="middle">${i + 1}</text>`);
|
| 403 |
+
});
|
| 404 |
+
for (const v of [-6, -4, -2, 0, 2, 4, 6].filter(v => Math.abs(v) < lim)) {
|
| 405 |
+
parts.push(`<text class="axis-t" x="${L - 8}" y="${y(v) + 3.5}" text-anchor="end">${v}</text>`);
|
| 406 |
+
}
|
| 407 |
+
parts.push(`<text class="lbl" x="${L + 6}" y="${y(Math.min(obf[0], lim)) + 15}" fill="var(--muted)">O'Brien-Fleming</text>`);
|
| 408 |
+
parts.push(`<text class="lbl" x="${L + 6}" y="${y(-zf) - 7}" fill="var(--muted)">not significant at 5%</text>`);
|
| 409 |
+
parts.push(`<text class="axis-t" x="${L}" y="${H - 10}" text-anchor="middle"></text>`);
|
| 410 |
+
svg.innerHTML = parts.join("");
|
| 411 |
+
|
| 412 |
+
const final = path[path.length - 1];
|
| 413 |
+
document.getElementById("zcap").textContent = cross >= 0
|
| 414 |
+
? `An analyst peeking every look would have stopped at look ${cross + 1} (z = ${path[cross].toFixed(2)}). The test ended at z = ${final.toFixed(2)}${Math.abs(final) < zf ? " — not significant." : "."}`
|
| 415 |
+
: `This test never crossed 1.96 at any look; it ended at z = ${final.toFixed(2)}.`;
|
| 416 |
+
}
|
| 417 |
+
|
| 418 |
+
// A reference label sits on top of marks, so it carries a card-coloured halo.
|
| 419 |
+
function refLabel(parts, x, y, text, anchor = "start") {
|
| 420 |
+
const w = text.length * 5.4 + 8;
|
| 421 |
+
const left = anchor === "end" ? x - w : x - 4;
|
| 422 |
+
parts.push(`<rect x="${left.toFixed(1)}" y="${(y - 9).toFixed(1)}" width="${w.toFixed(1)}" height="12" rx="3" fill="var(--card)" opacity=".92"/>`);
|
| 423 |
+
parts.push(`<text class="axis-t" x="${x}" y="${y}" text-anchor="${anchor}">${text}</text>`);
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
function axes(parts, W, H, L, R, T, B, xs, ys, xlab, fmt) {
|
| 427 |
+
const x = v => L + (W - L - R) * ((v - xs[0]) / (xs[1] - xs[0]));
|
| 428 |
+
const y = v => T + (H - T - B) * (1 - (v - ys[0]) / (ys[1] - ys[0]));
|
| 429 |
+
for (let i = 0; i <= 4; i++) {
|
| 430 |
+
const v = ys[0] + (ys[1] - ys[0]) * i / 4;
|
| 431 |
+
parts.push(`<line x1="${L}" x2="${W - R}" y1="${y(v).toFixed(1)}" y2="${y(v).toFixed(1)}" stroke="var(--grid)" stroke-width="1"/>`);
|
| 432 |
+
parts.push(`<text class="axis-t" x="${L - 7}" y="${(y(v) + 3.5).toFixed(1)}" text-anchor="end">${fmt(v)}</text>`);
|
| 433 |
+
}
|
| 434 |
+
parts.push(`<text class="axis-t" x="${(L + W - R) / 2}" y="${H - 4}" text-anchor="middle">${xlab}</text>`);
|
| 435 |
+
return { x, y };
|
| 436 |
+
}
|
| 437 |
+
|
| 438 |
+
function renderPeek() {
|
| 439 |
+
const by = DATA.peeking.aa_nulls.by_looks;
|
| 440 |
+
const looks = Object.keys(by).map(Number).sort((a, b) => a - b);
|
| 441 |
+
const W = 420, H = 210, L = 40, R = 14, T = 12, B = 30;
|
| 442 |
+
const parts = [];
|
| 443 |
+
const ymax = Math.max(...looks.map(k => by[k].naive)) * 1.15;
|
| 444 |
+
const sc = axes(parts, W, H, L, R, T, B, [0, looks.length - 1], [0, ymax], "times the analyst looks", v => (v * 100).toFixed(0) + "%");
|
| 445 |
+
const series = [["naive", "var(--orange)", "peek"], ["obrien_fleming", "var(--blue)", "O'B-F"], ["pocock", "var(--aqua)", "Pocock"]];
|
| 446 |
+
parts.push(`<line x1="${L}" x2="${W - R}" y1="${sc.y(0.05)}" y2="${sc.y(0.05)}" stroke="var(--muted)" stroke-dasharray="4 4" stroke-width="1.2"/>`);
|
| 447 |
+
refLabel(parts, L + 6, sc.y(0.05) - 5, "nominal 5%");
|
| 448 |
+
const labDy = { naive: -9, obrien_fleming: -9, pocock: 15 };
|
| 449 |
+
for (const [key, col, lab] of series) {
|
| 450 |
+
const pts = looks.map((k, i) => [sc.x(i), sc.y(by[k][key])]);
|
| 451 |
+
parts.push(`<path d="${pts.map((p, i) => (i ? "L" : "M") + p[0].toFixed(1) + " " + p[1].toFixed(1)).join(" ")}" fill="none" stroke="${col}" stroke-width="2.2"/>`);
|
| 452 |
+
pts.forEach((p, i) => parts.push(`<circle cx="${p[0].toFixed(1)}" cy="${p[1].toFixed(1)}" r="3.4" fill="${col}"><title>${lab}, ${looks[i]} looks: ${(by[looks[i]][key] * 100).toFixed(1)}%</title></circle>`));
|
| 453 |
+
parts.push(`<text class="lbl" x="${pts[pts.length - 1][0] - 4}" y="${pts[pts.length - 1][1] + labDy[key]}" text-anchor="end" fill="${col}">${lab}</text>`);
|
| 454 |
+
}
|
| 455 |
+
looks.forEach((k, i) => parts.push(`<text class="axis-t" x="${sc.x(i)}" y="${H - 17}" text-anchor="middle">${k}</text>`));
|
| 456 |
+
document.getElementById("c-peek").innerHTML = parts.join("");
|
| 457 |
+
}
|
| 458 |
+
|
| 459 |
+
function renderMult() {
|
| 460 |
+
const by = DATA.multiplicity.by_arms;
|
| 461 |
+
const ks = Object.keys(by).map(Number).sort((a, b) => a - b);
|
| 462 |
+
const W = 420, H = 210, L = 40, R = 14, T = 12, B = 30;
|
| 463 |
+
const parts = [];
|
| 464 |
+
const ymax = Math.max(...ks.map(k => by[k].false_positive_rate)) * 1.15;
|
| 465 |
+
const sc = axes(parts, W, H, L, R, T, B, [0, ks.length - 1], [0, ymax], "arms in the test", v => (v * 100).toFixed(0) + "%");
|
| 466 |
+
const bw = (W - L - R) / ks.length * 0.62;
|
| 467 |
+
ks.forEach((k, i) => {
|
| 468 |
+
const v = by[k].false_positive_rate;
|
| 469 |
+
parts.push(`<rect x="${(sc.x(i) - bw / 2).toFixed(1)}" y="${sc.y(v).toFixed(1)}" width="${bw.toFixed(1)}"
|
| 470 |
+
height="${(sc.y(0) - sc.y(v)).toFixed(1)}" rx="3" fill="var(--orange)"><title>${k} arms: ${(v * 100).toFixed(1)}% of null tests declare a winner</title></rect>`);
|
| 471 |
+
parts.push(`<text class="axis-t" x="${sc.x(i)}" y="${H - 17}" text-anchor="middle">${k}</text>`);
|
| 472 |
+
});
|
| 473 |
+
parts.push(`<line x1="${L}" x2="${W - R}" y1="${sc.y(0.05)}" y2="${sc.y(0.05)}" stroke="var(--muted)" stroke-dasharray="4 4" stroke-width="1.2"/>`);
|
| 474 |
+
refLabel(parts, W - R, sc.y(0.05) - 5, "nominal 5%", "end");
|
| 475 |
+
document.getElementById("c-mult").innerHTML = parts.join("");
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
boot().catch(err => {
|
| 479 |
+
document.querySelector(".wrap").insertAdjacentHTML("afterbegin",
|
| 480 |
+
`<div class="card" style="border-color:var(--orange)"><b>Could not load data.json.</b><br>
|
| 481 |
+
Run <code>make all</code> to build it, then start the service with <code>make serve</code>.</div>`);
|
| 482 |
+
console.error(err);
|
| 483 |
+
});
|
| 484 |
+
</script>
|
| 485 |
+
</body>
|
| 486 |
</html>
|