People and Products
How do you measure the people who use software, and when can you believe an experiment on them?
The part opens in San Francisco on 9 December 1968, with Engelbart's demonstration of the mouse, hypertext and shared editing. Its first half measures the person. Fitts's law comes out of Shannon's channel capacity, and a simulated hand that corrects its own errors falls on the line with R squared 0.99; Hick and Hyman make a choice cost its entropy, and the keystroke-level model predicts a task's time from its operators. Perception has thresholds at 0.1, 1 and 10 seconds, and colour has formulas: sRGB's transfer curve, OKLab, and the WCAG contrast ratio, applied to the series' own palette, whose red and orange nearly coincide under deuteranopia. The second half measures the product. The A/B test is a randomized trial with a two-proportion z-test and a sample size of about 16 sigma squared over delta squared per arm. The part turns on peeking: an A/A test checked every morning for a month declares a winner 28% of the time, and a mixture sequential test bounded by Ville's inequality repairs it. CUPED cuts variance by 1 minus rho squared, and the part ends with multiple metrics, sample-ratio mismatch, Simpson's paradox, bandits, and a marketplace where interference turns a measured +5.4 points into +0.2 at launch.
What you need. Logarithms, and a first course in probability: the binomial and normal distributions, variance and correlation.
- Mathematics, ideas and history
- Fitts and Hick from information theory, GOMS, perception, colour spaces and the WCAG contrast ratio, accessibility, usability, A/B tests, peeking and sequential tests, CUPED, interference
- What we build or compute
- A/B-test simulations; the series' palette checked
What you will be able to do
Degree
- Compute a target's index of difficulty and its predicted movement time from Fitts's law.
- Compute the WCAG contrast ratio of two sRGB colours from their relative luminances.
- Run a two-proportion z-test on an A/B test's counts and say what its p-value does and does not mean.
Graduate
- Derive the sample size per arm for a given lift, significance level and power.
- Explain why stopping at the first p below 0.05 inflates the false-positive rate, and derive the always-valid bound from Ville's inequality.
- Derive CUPED's optimal coefficient and its variance reduction of 1 - rho^2.
Research
- Explain why interference breaks the A/B estimate in a marketplace, and compare cluster and switchback designs that repair it.
- Derive the privacy parameter of Warner's randomized response and the accuracy it costs.
Industry
- Plan an experiment: the metric, the guardrails, the sample size and the stopping rule, fixed before the first look.
- Check a running test for sample-ratio mismatch and many-metric false discoveries before reading its result.
- Audit an interface for target size, contrast and colour-only encodings against WCAG 2.2.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Degree 23 min · Graduate 49 min · Research 52 min · Industry 39 min.
- 0The mother of all demosDegree2 min
- 1Pointing is a channelDegree4 min
- 2Choosing, and predicting a task's timeDegree3 min
- 3Perception and its thresholdsDegree3 min
- 4ColourDegree4 min
- 5Text on screensGraduate3 min
- 6AccessibilityIndustry3 min
- 7Evaluating usabilityIndustry4 min
- 8The A/B testDegree4 min
- 9Looking too oftenGraduate4 min
- 10Less noise, same truthGraduate3 min
- 11Pitfalls at scaleIndustry4 min
- 12Bandits and metricsIndustry4 min
- 13Frontier: measuring people, carefullyResearch3 min
- Recap, problems, and where this comes backAll tracks3 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · 中文 · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film.
The mother of all demosDegree2 min
On the ninth of December 1968, in San Francisco, Douglas Engelbart sat on a stage with a screen, a keyboard and a small wooden box with wheels underneath. For ninety minutes he showed a thousand engineers what a computer could be for a person. A pointer on the screen that followed his hand, through the box his lab had invented: the mouse. Words linked to other words, so that clicking one opened another: hypertext. A colleague thirty miles away, editing the same document at the same time, his face in a window on the screen. It was one working system, called NLS, from Engelbart's lab at the Stanford Research Institute. It came to be called the mother of all demos.
The ideas took fifteen years to reach ordinary desks. At Xerox PARC, the Alto of 1973 put windows, icons and a mouse on a personal machine. In 1979 Steve Jobs visited, and the Macintosh followed in 1984, Windows a year later. The web arrived in 1991, and multi-touch phones in 2007. Each step was an argument about people: what they can see, reach, remember and decide, and how quickly. This part treats those arguments as science.
Two kinds of measurement run through this part. The first is of people. The time to point at a target grows with the logarithm of its distance over its width, so precisely that the points fall on a line. That is Fitts's law, and it comes from Shannon's channel capacity. The second is of products: controlled experiments that compare two versions with real users. They have their own traps. Here, two identical versions are compared and checked every day for a month; 28 percent of these experiments declare a winner where there is none, against the five percent the test promises.
1Pointing is a channelDegree4 min
In 1954 the psychologist Paul Fitts asked people to tap a metal stylus back and forth between two plates, as fast as they could without missing. Each plate has a width, and the two are a distance apart. Move the plates farther apart, or make them narrower, and the taps slow down. Doubling the distance costs about as much as halving the width: only the ratio of distance to width matters, and the time grows with its logarithm. He had been reading Shannon, and he called his paper the information capacity of the human motor system.
Fitts's analogy was Shannon's channel capacity from Part 28. A channel's capacity in bits grows with the logarithm of one plus signal over noise. In pointing, the distance plays the signal and the width the noise the movement may tolerate. The index of difficulty, log of distance over width plus one, counts the bits a movement must deliver. This is Scott MacKenzie's form from 1992; it never goes negative, and it fits better than Fitts's original. Movement time is then a constant, for starting and stopping, plus a slope times the bits. The slope is seconds per bit, and its inverse is a throughput: the bandwidth of a hand.
Why a logarithm? David Meyer and colleagues, in 1988, gave an answer. A movement is a series of submovements. Each aims at the centre of the target and lands with an error proportional to the distance it covered; if it misses, another follows. So each correction shrinks the remaining distance by a roughly constant factor, and the number of corrections grows with the logarithm of distance over width. We simulated that hand on twenty targets, near and far, wide and narrow. The points fall on a line, with R squared of 0.99. The slope is 0.086 seconds per bit: a throughput of 11.6 bits per second for our simulated hand. People measured with a mouse manage a few bits per second, according to Soukoreff and MacKenzie in 2004.
Designers exploit a loophole. A pointer cannot leave the screen. Aim at a target on the edge and overshoot is impossible: the pointer stops there, as if the target were infinitely deep. In our simulation the same target takes 0.77 seconds in the middle and 0.40 at the edge: the hand can fling, and need not correct. That is why the Macintosh, in 1984, put a single menu bar at the very top of the screen, and why the corners, edges twice over, are the fastest places of all to reach.
Some movements must stay inside a path. To reach a submenu, the pointer travels along the parent item, and if it slips out on the way the submenu closes. Johnny Accot and Shumin Zhai showed in 1997 that steering through a tunnel takes time proportional to its length over its width, summed along the path. That is linear, not logarithmic, so tunnels cost far more than targets. Nested menus are tunnels in series. The remedies are wider items, shallower menus, and submenus that forgive a diagonal path towards them.
2Choosing, and predicting a task's timeDegree3 min
In 1952 William Hick lit one of several lamps and timed how long people took to press the key beneath it. Reaction time grew with the logarithm of the number of lamps plus one, the one counting the chance that no lamp lit at all. Here is a chooser who halves the candidates with each comparison, the binary search of Part 16. Seven lamps and the chance of none make eight possibilities, and three comparisons find any of them. We simulated that chooser, at a fifth of a second to start and about 0.15 seconds per comparison, for one to ten lamps. Time against bits is a line, with R squared of 0.999: each bit of uncertainty costs the same.
A year later Ray Hyman made the choices unequally likely, and reaction time followed the entropy of the choice rather than the number of options. Take a menu whose first item is chosen seventy percent of the time. Its entropy is 1.46 bits, against 2.32 for five equal choices. The best way to ask yes or no questions starts with the likely item: one question settles seventy percent of cases, and three settle the rest, 1.6 questions on average. That is the Huffman code of AI, Built Part 1, and it is never shorter than the entropy. The design rule follows: put the likely choice first, or make it the default.
Stuart Card, Thomas Moran and Allen Newell turned these laws into an engineering tool. Their GOMS analysis describes a task as a goal, such as deleting a file; methods that achieve it, each a sequence of elementary operators: reach for the mouse, point, click, press a key; and selection rules for choosing between methods. Give every operator a time, and you can predict how long a task will take before anyone has built it.
The keystroke-level model, which Card, Moran and Newell published in 1980, is the simplest version; the button press was added in later guides by David Kieras. A keystroke takes 0.28 seconds for an average typist, pointing with a mouse 1.1, a button press a tenth, moving a hand between keyboard and mouse 0.4, and a moment of mental preparation 1.35. Write each method as a string of operators and add them up. Deleting a file through a menu: 5.5 seconds. With a shortcut: 5.26. Renaming through a dialog: 9.47; inline: 8.85. The yellow blocks are moments of thought, and they dominate. A faster design is usually one that asks for fewer decisions, not fewer keys.
3Perception and its thresholdsDegree3 min
The first thresholds are in time. In 1968 Robert Miller, at IBM, asked how fast a computer must answer a person, and the answer has been restated ever since, by Card, Robertson and Mackinlay in 1991 and by Jakob Nielsen in 1993. Under a tenth of a second, a response feels instantaneous: the result itself is all the feedback needed. Under a second, the delay is noticed, but the user's flow of thought is not broken. Under ten seconds, attention holds, if the interface shows that work is happening. Beyond that, people turn away: show real progress, and let them do something else.
Direct manipulation is stricter than a tenth of a second. When you drag something under your finger, any delay shows as a gap between the finger and the thing. In 2012 Albert Ng and colleagues at Microsoft Research built a touch screen with almost no delay, and found that people dragging on it could notice latencies of only a few milliseconds. Every input travels a pipeline: the sensor, the operating system, the application, rendering, compositing and the display. Each stage that waits for the next frame can add a whole frame, sixteen point seven milliseconds at sixty hertz, the frame budget of Part 42. Latencies add, so each stage must be budgeted.
The second kind of threshold is in size. Two short bars differ by a tenth of a unit, and the difference is easy to see. Add the same tenth to a long bar and it nearly vanishes. To be as visible, the difference must grow with the bar. Ernst Weber found this in the 1830s: the just-noticeable difference is a fixed fraction of the stimulus, a fraction that differs from one sense to another. Gustav Fechner, in 1860, counted those steps, and concluded that sensation grows with the logarithm of the stimulus. It is why loudness is measured in decibels, and, as the next chapter shows, why screens spend more codes on dark tones.
Some differences need no search at all. One red mark among blue ones is seen at once, however many blue ones there are. So is one tilted line among upright ones. Colour, size, orientation and motion are processed in parallel across the whole field of view, before attention arrives. But find the red tilted line here, among red upright lines and blue tilted ones. Each feature alone is everywhere, and the eye has to check the marks one by one. Anne Treisman and Garry Gelade made this the feature integration theory in 1980. For an interface: mark the one thing that matters with a single feature.
4ColourDegree4 min
Light is a spectrum, energy spread across wavelengths. The eye measures it with three kinds of cone, sensitive to short, medium and long wavelengths. Whatever the spectrum, it is reduced to three responses. Two spectra with the same three responses look identical: metamers, which is why three primaries can imitate most colours we see. In 1931 the CIE fixed a standard observer from colour-matching experiments, the XYZ space. The sRGB standard, from HP and Microsoft in 1996, defines three primaries and a white in XYZ, and almost every screen and web page assumes it.
An sRGB pixel stores code values from 0 to 255, and they are not amounts of light. The transfer curve, close to a power of 2.4, maps code to light. Code 128, the middle of the range, emits only 21.6 percent of white's light. Half of white's light is this much paler grey, b c b c b c. The curve is there because of Weber and Fechner: equal steps of code are roughly equal steps of perceived lightness, so the codes are spent where the eye can tell them apart. The price is that mixing, scaling and lighting must convert to linear light first, a theme of Part 51.
Code values say nothing about how different two colours look. Every colour a screen can show sits in this cube of red, green and blue. Perceptual spaces bend that cube so that distance means difference. CIELAB, from 1976, gives lightness and two opponent axes, green to red and blue to yellow. OKLab, published by Björn Ottosson in 2020, is refitted so that equal distances look more nearly equal and hues stay put as colours lighten. Here is this series' own palette in it, and the cube's red corner. Our conversions pass the checks: white has lightness one hundred in CIELAB and one in OKLab, and sRGB red lands on the published value.
About eight percent of men of European ancestry, and half a percent of women, have a colour-vision deficiency, mostly red and green; those are approximate published figures. Here is this series' palette, as typical vision sees it. Below it, the same six colours simulated for the three kinds of missing cone, with the model of Machado, Oliveira and Fernandes from 2009. For each view, the closest pair in OKLab. The honest finding is about us. Under deuteranopia, the red this series uses for false and the orange it uses for the kernel are only 0.014 apart: nearly the same colour. Red means wrong in these videos, so red can never be the only signal.
Colour also decides whether text can be read. The contrast ratio of the Web Content Accessibility Guidelines compares relative luminances, computed in linear light, each plus a small constant for glare. Every colour in our palette clears 4.5, the level asked for ordinary text, on the dark background; three of them also clear seven. Contrast is not enough, though. A chart that separates two series by red and orange alone becomes one series under deuteranopia. Give each series a shape and a direct label as well, and the chart survives. The lesson: never use colour alone; add shape, position or a label.
5Text on screensGraduate3 min
A letter on a screen begins as a shape, not as pixels. A font stores each glyph as an outline: closed paths of Bézier curves, pinned by anchor points on the curve and pulled towards control points off it. TrueType, released by Apple in 1991, uses quadratic curves; PostScript fonts use cubic ones. Either way, one outline serves every size. To draw it, lay the pixel grid over the outline and ask whether each pixel's centre is inside: count how often a ray from the centre crosses the outline, using Part 22's orientation test. An odd count means inside. Part 51 will rasterize triangles the same way.
Here is the word Job, drawn by FreeType, the open-source rasterizer, at four sizes. With one bit per pixel, each pixel is on or off. At 8 pixels the whole word gets 23 by 11 of them, and the curves turn into staircases. Antialiasing lets a pixel be partly on: its grey is the share of it the outline covers, so an edge a third of the way across a pixel still shows where it is. The small word uses 41 levels of grey, the large one 111. At eight pixels a stroke is about one pixel wide, and where it lands matters.
Coverage alone does not make small text sharp. Here are three identical stems, like the legs of an m, each one and four tenths of a pixel wide. One becomes a grey smear across two pixels, one is solid on one side, one spreads over three. Equal strokes look unequal. Hinting fixes this. A TrueType font carries small programs, bytecode for a stack machine inside the rasterizer, that move the outline's points onto pixel boundaries at each size, so every stem comes out one crisp pixel wide. It matters most at eight to twelve pixels, where a stroke is a single pixel, and much less on dense screens.
A liquid-crystal pixel is really three stripes: red, green and blue. Treat the pixel as a unit, and a stem starting a third of the way in becomes two dim greys. Light the stripes one by one, and the edge can be placed to a third of a pixel: the horizontal resolution triples. Microsoft shipped this as ClearType in Windows XP, with a filter that spreads each edge across neighbouring stripes to hide the colour fringes. It needs to know the stripe order, so rotating a tablet breaks it; once screens were dense enough, Apple turned it off in macOS, in 2018.
6AccessibilityIndustry3 min
Accessibility is design for people whose bodies or minds differ from the designer's. The World Health Organization estimates that about one point three billion people, sixteen per cent of the world, live with a significant disability. And the line is blurry. Microsoft's inclusive design toolkit draws a spectrum: a person with one arm, a person with a broken arm and a parent holding a baby all need a phone that works one-handed. The same goes for blindness, a cataract and a driver's eyes on the road, and for deafness, an ear infection and a noisy bar. Disability is a mismatch between a person and a design, and with age almost everyone meets one.
Each kind of assistive technology asks something different of software. A screen reader speaks the accessibility tree that Part 42 built from the page: this is a button, named Buy. Someone who can press only one or two switches, with a hand, a foot or a breath, steps a highlight through the controls, so every action must be reachable in that order. Magnifiers enlarge the screen; the guidelines ask that text resize to twice its size, and that a page still work at three hundred and twenty pixels wide. Voice control acts on names: say click Buy, and it must find a control whose accessible name contains the visible word.
Chapter one's law has an accessibility reading. For a given reach, a wider target is quicker to hit. With chapter one's fit, a sixteen-pixel target four hundred and eighty pixels away takes about 759 milliseconds, a forty-four-pixel one 640. For someone with a tremor, whose hand scatters widely, the difference decides whether the target can be hit at all. WCAG 2.2 sets a minimum of twenty-four by twenty-four CSS pixels, or enough space around a smaller target. And anything done by dragging must also work with a single tap, and everything with a keyboard.
Some disabilities affect memory, attention or reading. For them, and for everyone who is tired or in a hurry, the rules are mostly restraint: plain words, short sentences, and navigation that stays the same from page to page, so nothing has to be relearned. A time limit should come with a warning and a way to extend it, or not exist. WCAG 2.2 added that signing in must not depend on remembering or solving a puzzle: let a password manager fill the field, and let people paste. And video needs captions, including the sounds that matter, for deaf viewers, and for everyone watching on a train with the sound off.
7Evaluating usabilityIndustry4 min
How do you find out what is wrong with a design before your users do? The cheapest way is to inspect it. In 1994 Jakob Nielsen distilled ten rules of thumb from hundreds of usability problems: show people what the system is doing, speak their language, let them undo, be consistent, prevent errors, make choices visible instead of remembered, and so on. In a heuristic evaluation, a few evaluators each check the design against the list on their own, then pool what they found. It is fast and cheap. But it finds the problems experts expect, and real people find others.
To find what real people stumble on, watch them. In a think-aloud study a participant is given real tasks, like buying a ticket for a friend, and asked to say what they are thinking as they work. Every hesitation, wrong guess and retreat marks a problem, and the words say why: the person did not know where to say the ticket was for someone else. The facilitator stays quiet, and never helps. Clayton Lewis brought the method into interface design at IBM in 1982, from the psychology of verbal reports. The rule is to watch what people do, and not to ask what they would do.
How many participants are enough? Jakob Nielsen and Thomas Landauer answered with a model in 1993. Suppose each user, independently, runs into each problem with the same probability L. Averaged over the projects they studied, L was about 0.31. One user misses a given problem with probability one minus L. All n users miss it with probability one minus L to the power n, because independent chances multiply, as in Part 2. So the share of problems found is one minus that. One user finds 31 per cent, two find 52, three 67, four 77, and five 84: the famous claim that five users find most of the problems.
The model assumed every problem is equally easy to find. Real ones are not. Here is the curve when each problem is found with the same probability. Now let visibility vary: a few problems hit almost everyone, many hit only a few. We drew each problem's probability from a Beta distribution with the same average, point three one. With five users the share found falls from 84 to 71 per cent. To find 84 per cent now takes 11 users, because the problems few people hit are the ones that take longest to see, and the average hides them.
So the five-user rule needs care. L is an average over projects, and it varies with the product, the task and the people. A problem that only one user in twenty hits is found by five users less than a quarter of the time, however severe it is, which is why rare but costly failures need other methods too: logs, support calls, and the experiments of the next chapter. What the curve does support is iteration. One round of fifteen users would find nearly everything in today's design, but most of it is found by the first five; fix that, and the next five find the problems the old ones were hiding. Nielsen's own advice was three rounds of five.
8The A/B testDegree4 min
Where intuition runs out, run an experiment. Each arriving user is assigned by a coin: heads, the current page; tails, the new one. Because a coin decides and not a person, the two groups differ only by chance, in every trait, even ones nobody measured, such as how many are returning customers. With large groups, Part 20's concentration makes their averages nearly equal. So if the groups then behave differently, the cause is the change, or chance. This is Ronald Fisher's randomized experiment, and a statistical test measures the chance.
Here is the standard test. Each arm converts a share of its users, and the observed difference is B's rate minus A's. Suppose the change did nothing: then both arms share one rate, estimated by pooling them. A rate's variance is p times one minus p over n, and the two arms' variances add. Divide the difference by the resulting standard error. For large samples z is nearly standard normal, and the p-value is the chance of a z this far from zero if nothing changed. Five hundred conversions against five hundred and sixty, out of ten thousand each, is a twelve per cent lift, yet z is only 1.89 and the p-value 0.058: not significant at five per cent.
A test can be wrong in two ways. If the change did nothing, the estimated difference scatters around zero, with a spread of one standard error. We declare a winner beyond one point nine six of them, so we are fooled five per cent of the time: that is alpha. If the change really helps by delta, the estimate scatters around delta instead, and whenever it falls short of the line we miss a real effect: that is beta, and one minus beta is the power. For eighty per cent power, delta must sit nought point eight four standard errors beyond the line.
That picture is a recipe for the sample size. Delta must be one point nine six plus nought point eight four standard errors, and the standard error is sigma times the root of two over n. Solve for n. The constant comes to fifteen point seven, so n is about sixteen sigma squared over delta squared: every experimenter's rule of thumb. On a five per cent conversion rate, a five per cent relative lift needs about 119 thousand users in each arm; the rule says 121.6 thousand. Halve the lift and you need four times as many: a one per cent lift needs about 3 million per arm.
Formulas built on approximations deserve a check. We simulated two thousand experiments with a true five per cent lift and 119,302 users per arm. The test found the lift in 78.9 per cent of them, the eighty per cent we designed for, to within the simulation's noise. With half the users, the standard error grows by the square root of two, and delta now sits barely past the line. Power falls to 50 per cent: a real improvement missed half the time. Worse, when such a test does come out significant, it overstates the effect, because only the lucky overestimates cross the line.
9Looking too oftenGraduate4 min
Here is an experiment with nothing in it: two identical versions, an A/A test, with a thousand users a day in each and a conversion rate of five percent. Every morning someone runs last chapter's z-test on everything so far. With no difference, the p-value has nowhere to settle. On any one day it is equally likely to be anywhere between zero and one, and from day to day it wanders, sometimes close to the red line. Of these six, one falls below it, on the last morning. Look often enough, and any of them might.
Now simulate four thousand of them, and stop each one the first morning its p-value falls below five percent, declaring a winner. On the first day, 5 percent stop, as promised. After a week, 17 percent have stopped. After two weeks, 23. By day thirty, 28 percent of experiments with no effect at all have announced one. The same experiments, looked at only once, at the end, give 4 percent. The test was never wrong; the stopping rule was. Five percent is a promise about one look, not thirty.
Why does looking hurt? Turn each p-value back into its z-statistic. The test rejects when z rises above one point nine six. With no real difference, z is a random walk divided by the square root of its length: Part 20's concentration, in motion. The law of the iterated logarithm, proved by Aleksandr Khinchin in 1924, says its peaks keep returning to about the square root of two log log n, which grows without limit. So a walk watched forever crosses any fixed line. Thirty separate tests would give 79 percent false positives; daily looks share most of their data, so we saw 28, but every look adds some.
The fix is a test built to be watched. Abraham Wald's sequential test compared the likelihood of the data under an effect with its likelihood under none; Herbert Robbins, in 1970, averaged that ratio over a range of plausible effects. Stop when it reaches one over alpha, twenty. With no effect, the ratio is a fair bet: its expected value stays one however long you play, and Ville's inequality says it ever reaches twenty with probability at most one in twenty. In z units the boundary is no longer flat: it starts high and comes down slowly. Ramesh Johari, Pete Koomen, Leonid Pekelis and David Walsh turned this into always-valid p-values, safe to check every morning.
We ran the mixture test on the same traffic, checked daily. Daily z-tests had 28 percent false positives. The mixture test, its spread tuned to five percent lifts, had 0.4 percent; tuned to ten percent lifts, 1.2. Both under five. Now give the new version a real ten percent lift. Within thirty days the first catches it 39 percent of the time, at a median of day 22, and the second 51 percent, by day 18. A fixed test with eighty percent power needs almost thirty thousand users per arm: the whole month, and one look. That is the trade: valid at every look, paid for in power.
10Less noise, same truthGraduate3 min
Most of the variation in a metric has nothing to do with the experiment. A user who spent a lot last month will probably spend a lot this month, whatever version they see. Plot each user's metric during the experiment against the same metric in the month before. The spread of the metric is mostly who the user is. In 2013 Alex Deng, Ya Xu, Ron Kohavi and Toby Walker, at Microsoft, called the remedy CUPED. Subtract from each user what their past predicts: theta times their pre-period metric, less its average. The cloud flattens, and the spread shrinks. The difference between the versions is untouched.
How much does it help? Expand the variance of the adjusted metric: the variance of Y, minus twice theta times the covariance, plus theta squared times the variance of X. It is a parabola in theta, smallest where the derivative vanishes: at the covariance over the variance of X, the slope of the regression line. Put that back, and the variance is the plain one times one minus rho squared, rho being the correlation of past and present. And the truth is the same, because X was measured before randomization: both groups have the same average past, in expectation, so the adjustment removes noise and not effect. Hence the one rule: never adjust by anything the treatment could change.
We checked the formula on simulated experiments: twenty thousand users per arm, repeated two thousand times for each of five correlations. The blue bars are the measured variance with CUPED, divided by the variance without; the yellow marks are one minus rho squared. They agree, from no help at all when the past says nothing, to a variance cut to 0.50 at a correlation of point seven, and 0.19 at point nine. Variance falls as one over the number of users, so a correlation of point seven is worth about 2 times the traffic, and point nine about 5 times: weeks of experiment, for one line of arithmetic.
Here is what that means for one experiment's conclusion. The true effect is point zero two standard deviations. Without CUPED, the ninety-five percent interval reaches almost as far as the effect itself on either side, and only just clears zero. Now raise the correlation with the past. At point five the interval narrows a little; at point seven, by 29 percent; at point nine, by 56 percent, to less than half its width. The same users and the same effect; the only thing removed is the noise that each user's own history already explained.
11Pitfalls at scaleIndustry4 min
Experiments report dozens of metrics. Take twenty, and a change that moved none of them. Each has a five percent chance of looking significant. Run the experiment, and one metric lights up; run another, and a different one does. The chance that at least one lights up is one minus point nine five to the twentieth, 64 percent; our simulation found 64. Report the metric that moved, and you have usually reported noise: Part 2's counting, turned against us.
The cure is to be less impressed the more you look. Bonferroni divides the threshold by the number of tests: safe, but strict. In 1995 Yoav Benjamini and Yosef Hochberg proposed a gentler line: sort the p-values, and compare the i-th smallest with alpha times i over k. Everything up to the last point under the line is a discovery. This controls the false discovery rate, the expected share of discoveries that are false. With nothing real, only 5 percent of our experiments made any.
Before reading any metric, check the split. A fifty-fifty test that ends with 50,000 users in one arm and 49,000 in the other looks close. Pearson's chi-squared test disagrees: chi-squared is 10.1, and a gap this large happens by chance about 15 times in ten thousand. 50,100 against 49,900 is ordinary luck. A mismatch means something removed users unevenly: a redirect, a bot filter, a crash that stops one version logging. The users who remain are no longer comparable, so every metric is suspect.
Averages can reverse. A redesign converts better on desktop, 11.2 percent against 10, and better on mobile, 5.8 against 3. Yet overall it converts worse: 6.5 percent against 7.7. Its visitors were mostly on mobile, where everyone converts less, and the overall rate weights segments by traffic: Simpson's paradox, after Edward Simpson's paper of 1951. A randomized test gives both arms the same mix, so a mix like this is itself a warning: the split changed midway, or nothing was randomized.
A two-week test measures two weeks of behaviour. A new button gets clicked because it is new: the novelty effect, a lift that fades. The opposite is primacy: people used to the old design stumble at first. So plot the effect against days since each user first saw the change, look at new users, who have no habits, and run until the curve flattens. And when users affect each other, as buyers in a marketplace do, the test itself is biased; that is for the frontier chapter.
The last pitfall is wanting to believe. Twyman's law, named after the British audience researcher Tony Twyman and made a rule of experimentation by Ron Kohavi: any figure that looks interesting or different is usually wrong. A test reports revenue up thirty-eight percent. Before celebrating, check the split, check whether logging changed, look for bots or one enormous customer, and run an A/A test through the same pipeline. Real improvements are usually small. A huge one is usually a bug.
12Bandits and metricsIndustry4 min
An A/B test gives the worse version half its traffic until the end, on purpose. A bandit, named after the casino's one-armed bandits, shifts traffic while it learns. Part 26 of AI, Built met the oldest good rule, Thompson sampling, from William Thompson in 1933. Keep a belief about each version's conversion rate. For each visitor, draw one plausible rate from each belief, and show the version whose draw is higher. As evidence arrives the beliefs narrow, and a version is tried exactly as often as it might still be the best.
We raced the two on 100,000 visitors, with versions converting 5 and 5.5 percent. The fifty-fifty split loses about 253 conversions against always showing the better one: its regret. Thompson sampling loses about 48. But look at what each learns. The split measures the difference with a standard deviation of 0.14 points. The bandit, having starved the worse version, is about 5 times less precise, and its interval easily includes zero. So: bandits for optimizing, when only the reward matters, like a headline that lives a day; A/B tests for learning how big an effect is.
An experiment must know what better means. Companies choose a north-star metric, the one number that stands for value delivered to users, here weekly active buyers. Under it sit driver metrics that move faster and that a team can actually change. Beside them are guardrails: load time, crashes, unsubscribes, support tickets, which must not get worse whatever else improves. A change ships when the overall evaluation criterion, as Ron Kohavi calls it, improves and no guardrail regresses.
Any metric can be gamed by the experiments meant to improve it. The economist Charles Goodhart observed it of monetary targets in 1975; the anthropologist Marilyn Strathern gave it the famous wording: when a measure becomes a target, it ceases to be a good measure. Push hard on clicks and clickbait wins; the metric keeps rising after what it stood for starts to fall. A learning system finds that gap faster than any person: reward hacking, from Part 31 of AI, Built. The defences: several metrics, guardrails, long holdouts, and asking users.
A short-term number can also turn a product against its users. In 2010 the designer Harry Brignull named dark patterns: designs that trick people into doing what they did not mean to. One click to subscribe, six steps to leave. A box ticked in advance. A cost that appears at the last step. A refusal button that mocks you. And an experiment that counts only today's sign-ups will discover these by itself, and call each a win.
Every A/B test is an experiment on people, usually a harmless one. In 2014 Adam Kramer, Jamie Guillory and Jeffrey Hancock reported that for one week in January 2012, about six hundred and eighty-nine thousand Facebook users had been shown fewer positive posts, or fewer negative ones. Their own posts shifted slightly the same way. The reaction was strong: no one had been asked, and the journal published an editorial expression of concern. The Belmont Report of 1979 asks research on people for respect for persons, beneficence and justice; few product tests meet an ethics board, but the principles apply. Measuring without watching anyone is for the frontier.
13Frontier: measuring people, carefullyResearch3 min
What can an experiment not see? Every test in this part assumed that what happens to one user does not depend on what happens to another. Marketplaces break that. We simulated ten thousand buyers and three thousand items. The treatment makes buyers six points keener. But supply is limited, so every extra item a treated buyer takes is one a control buyer cannot have. The A/B test reports a lift of 5.4 points. Launch the treatment to everyone, and sales rise by 0.2: almost nothing, because supply was the limit all along. With ample supply the two agree. The fixes randomize whole units that do not interact: entire cities, or alternating time slots, called switchbacks, and in social networks, clusters of friends, as Johan Ugander and colleagues proposed in 2013. Designing experiments under interference is an active field.
A second limit is time. A test runs for two weeks; what a company cares about, whether people are still using the product next year, takes a year to see. Novelty fades, habits form, and a short test can point the wrong way. One answer is the surrogate index of Susan Athey, Raj Chetty, Guido Imbens and Hyunseung Kang: learn, from many past experiments, how short-term signals predict the long-term outcome, and use that prediction as the metric. Another is a long-running holdout: a few users kept on the old product for months, against whom the accumulated effect of many launches is measured. When a surrogate can be trusted, and how wrong it can be, are open questions.
A third limit is privacy: some things should be measured without anyone being watched. The oldest trick is Stanley Warner's randomized response, from 1965. Ask a sensitive question. Each person answers truthfully three times in four, and otherwise flips a coin and gives that answer instead. No single answer reveals anything certain, but the rate in the population can be recovered by undoing the known noise. The price is precision: with a true rate of twenty percent, the private estimate's error is about one and a half times that of an honest survey of the same size, at every size we tried. In today's language this is local differential privacy, with epsilon of about 1.9. Google's RAPPOR used it for browser statistics in 2014, Apple for keyboard statistics in 2016, and the 2020 United States Census applied differential privacy centrally to its published tables.
Recap, problems, and where this comes backAll tracks3 min
What we built in this part. Fitts's law, out of a noisy channel of corrected movements, and Hick's law, out of the entropy of a choice. Predictions of task time from a few operators. Colour as formulas, and this series' own palette checked for contrast and for colour-blind viewers. The number of users a usability study needs, and why the famous five can be too few. The A/B test and its sample size, the false winners that come from looking every day, a sequential test that is safe to look at, and CUPED, which removes the variance a user's past already explains. One idea runs through it: people can be measured, but measuring them well takes the same care as any other experiment.
Where this comes back. Parts 45 and 50 run experiments on infrastructure itself, as canaries and staged rollouts. Part 46 builds the pipelines that log every event these experiments analyse. Part 47 ranks search results and measures whether the ranking helps. Part 51 draws glyphs and colour on the GPU. And Part 57 asks the deeper version of this part's statistical questions: when does what we measured on some people generalize to the rest?
In practice. Make frequent targets big and close, and use the screen's edges and corners. Respond within a tenth of a second, show progress after a second, and let people do something else after ten. Give text a contrast of at least four and a half to one, never use colour as the only signal, and look at your design through a colour-blind simulation. Test with a few users, often, fixing what they find between rounds. And fix an experiment's sample size before it starts, or use a sequential test, and always check that the split is the one you asked for.
Six problems, with full solutions in the part's notes. Pause on any of them. The fifth is a build problem: correct for daily peeking the old-fashioned way, by dividing alpha among thirty looks, and compare its power with the sequential test. The last, marked with a star, is a research problem: a sequential test that stays valid when the people in an experiment affect each other.
Next time, Part 45, and the start of Act Nine: the cloud. A modern application rents its computer by the second, from a building the size of a stadium. Underneath sit power and cooling budgets, virtual machines shrunk to micro-VMs, containers placed by bin packing, and control loops that keep making what is match what should be.
The books and papers this part follows are on screen and in the notes. Thank you for watching.
Where it goes next. Parts 45 and 50 run experiments on infrastructure itself, as canaries and staged rollouts. Part 46 builds the pipelines that log every event these experiments analyse, and Part 47 ranks search results and measures whether the ranking helps. Part 51 draws glyphs and colour on the GPU, and Part 57 asks when what was measured on some people generalizes to the rest.
Key results
The part's results in one place, for revision.
Try it
Lab 44 · Peeking, a sequential test, and CUPED
Simulate A/A tests with the series' experiment tools: z-test them every day and stop at the first p < 0.05, look only once on day 30, or use the mixture sequential test; then check CUPED's variance against 1 - rho^2, the sample-size formula against simulated power, and Fitts's law on a simulated hand.
python -m videos.cs.labs 44
needs numpy, scipy, matplotlib · download lab44.py ·
source on GitHubA/A test, one look on day 30 4.7% declare a winner (promised 5%)
A/A test, stopped at the first p < 0.05 5.3% on day 1, 15.9% by day 7, 27.1% by day 30
mixture sequential test, looked at daily 0.2% false positives; finds a real 10% lift 38% of the time
CUPED variance ratio at rho = 0.5, 0.7, 0.9 0.79 0.55 0.17 (1 - rho^2: 0.75 0.51 0.19)
10% lift on a 5% rate 29,826 users per arm (rule of 16: 30,400); simulated power 79.0%
Fitts's law, 20 simulated targets MT = 0.33 + 0.087 log2(D/W + 1) s, R^2 = 0.994
A z-test promises 5% false positives for one look; stopping at the first significant morning turns that into more than 20% in a month. A test built as a martingale keeps its promise at every look, and a pre-period covariate buys precision without more users.
The code (78 lines; it asserts its own result)
"""Lab 44: run A/A tests that are checked every morning, repair them with a sequential test, and cut their noise with CUPED."""
from videos.coursekit import labs # noqa: I001 (must stay first: it lets explainer.cs import without manim)
import numpy as np
from explainer.cs.people import experiments as ex
from explainer.cs.people import hci
TITLE = "Peeking, a sequential test, and CUPED"
GOAL = ("Simulate A/A tests with the series' experiment tools: z-test them every day and stop at the first p < 0.05, "
"look only once on day 30, or use the mixture sequential test; then check CUPED's variance against 1 - rho^2, "
"the sample-size formula against simulated power, and Fitts's law on a simulated hand.")
TASKS = [
"Run ex.peeking with days=90. Does the false-positive rate level off? Compare its growth with the law of the iterated logarithm's sqrt(2 log log n).",
"Call ex.msprt with lift=0.10 and tau2=(0.05 * 0.10) ** 2, then with the default tau2. Which mixture stops earlier on a real 10% lift, and what does each do to an A/A test?",
"In ex.cuped, use theta = 1 instead of the regression slope (edit a copy). At which correlations does the adjusted estimator become noisier than the plain one?",
]
def run(seed=0):
lab = labs.Lab()
# 1. an A/A test, 1,000 users a day per arm, 5% converting: a look every morning against one look
peek = ex.peeking(days=30, per_day=1000, p=0.05, trials=3000, seed=seed)
by_day = np.array(peek["fpr_peeking"])
assert abs(by_day[0] - 0.05) < 0.02 and abs(peek["fpr_final_only"] - 0.05) < 0.02, "one look keeps its 5%"
assert by_day[-1] > 0.20 and np.all(np.diff(by_day) >= 0), "thirty looks do not"
lab.row("A/A test, one look on day 30", f"{peek['fpr_final_only']:.1%} declare a winner (promised 5%)")
lab.row("A/A test, stopped at the first p < 0.05", f"{by_day[0]:.1%} on day 1, {by_day[6]:.1%} by day 7, "
f"{by_day[-1]:.1%} by day 30")
# 2. the mixture sequential test: valid at every look (Ville's inequality), and it still finds a real lift
null, real = ex.msprt(lift=0.0, trials=3000, seed=seed), ex.msprt(lift=0.10, trials=3000, seed=seed)
assert null["rejected"] <= 0.05, "always valid: at most alpha, however often one looks"
assert real["rejected"] > 0.25, "and it has power against a real 10% lift"
lab.row("mixture sequential test, looked at daily", f"{null['rejected']:.1%} false positives; "
f"finds a real 10% lift {real['rejected']:.0%} of the time")
# 3. CUPED: the variance falls by the factor 1 - rho^2
rhos = [0.0, 0.3, 0.5, 0.7, 0.9]
ratios = [ex.cuped(n=1000, rho=r, trials=800, seed=seed + k)["ratio"] for k, r in enumerate(rhos)]
for r, got in zip(rhos, ratios):
assert abs(got - (1 - r * r)) < 0.25 * (1 - r * r) + 0.02, "Var(Y - theta X) = Var(Y)(1 - rho^2)"
lab.row("CUPED variance ratio at rho = 0.5, 0.7, 0.9", " ".join(f"{g:.2f}" for g in ratios[2:])
+ " (1 - rho^2: 0.75 0.51 0.19)")
# 4. the sample size that buys 80% power, and the rule of 16
size = ex.sample_size(0.05, 0.10)
power = ex.power_sim(p=0.05, lift=0.10, trials=3000, seed=seed)["power"]
assert abs(power - 0.80) < 0.05 and abs(size["rule_16"] / size["n_per_arm"] - 16 / 15.7) < 0.01
lab.row("10% lift on a 5% rate", f"{size['n_per_arm']:,.0f} users per arm (rule of 16: {size['rule_16']:,.0f}); "
f"simulated power {power:.1%}")
# 5. Fitts's law on the simulated hand
fitts = hci.fitts_experiment(seed=seed, trials=200)
assert fitts["r2"] > 0.97 and fitts["b"] > 0
lab.row("Fitts's law, 20 simulated targets", f"MT = {fitts['a']:.2f} + {fitts['b']:.3f} log2(D/W + 1) s, R^2 = {fitts['r2']:.3f}")
lab.note = ("A z-test promises 5% false positives for one look; stopping at the first significant morning turns "
"that into more than 20% in a month. A test built as a martingale keeps its promise at every look, "
"and a pre-period covariate buys precision without more users.")
fig, ax = labs.figure(2, size=(11, 4.4))
days = np.arange(1, 31)
ax[0].plot(days, 100 * by_day, "o-", ms=4, color=labs.RED, label="z-test every morning, stop at p < 0.05")
ax[0].axhline(100 * peek["fpr_final_only"], color=labs.BLUE, label="z-test once, on day 30")
ax[0].axhline(100 * null["rejected"], color=labs.GREEN, label="mixture sequential test, every morning")
ax[0].axhline(5, color=labs.MUTED, ls="--", label="promised: 5%")
ax[0].set(title="A/A tests that declare a winner", xlabel="day", ylabel="false positives so far (%)")
ax[0].legend(loc="center right")
grid = np.linspace(0, 0.95, 50)
ax[1].plot(grid, 1 - grid ** 2, color=labs.GOLD, label="theory: 1 - rho²")
ax[1].plot(rhos, ratios, "o", color=labs.BLUE, label="800 simulated experiments each")
ax[1].set(title="CUPED: variance left after adjusting", xlabel="correlation rho with the pre-period metric",
ylabel="Var(adjusted) / Var(plain)", ylim=(0, 1.15))
ax[1].legend()
lab.fig = fig
return lab
Now change it
- Run ex.peeking with days=90. Does the false-positive rate level off? Compare its growth with the law of the iterated logarithm's sqrt(2 log log n).
- Call ex.msprt with lift=0.10 and tau2=(0.05 * 0.10) ** 2, then with the default tau2. Which mixture stops earlier on a real 10% lift, and what does each do to an A/A test?
- In ex.cuped, use theta = 1 instead of the regression slope (edit a copy). At which correlations does the adjusted estimator become noisier than the plain one?
Problems, with solutions
Try each problem before opening its solution.
-
Fitts from submovements. Derive Fitts's law from submovements whose endpoint error is proportional to the distance they cover, and say what sets the slope b.
Solution
Let dₖ be the distance left after k submovements, d₀ = D. Each submovement aims at the centre and lands with an error proportional to the distance it covered, so dₖ₊₁ = σ|Zₖ|·dₖ with Zₖ independent and σ the relative precision of the hand (σ = 0.2, Zₖ standard normal, in our instrument). The movement ends at the first k with dₖ ≤ W/2, that is, when Σ log₂(1/(σ|Zᵢ|)) ≥ log₂(2D/W). Each submovement therefore delivers, on average, μ = E log₂(1/(σ|Z|)) = log₂(1/σ) − E log₂|Z| bits of the log₂(2D/W) the target asks for, and by the renewal theorem the number of submovements is N ≈ log₂(2D/W)/μ plus a constant (the last one overshoots the threshold). With a time t per submovement after a reaction time t₀, MT = t₀ + t·N ≈ a + b log₂(2D/W), Fitts's own form, with
b = t/μ, so 1/b = μ/t bits per second.
The slope is set by how long a correction takes and how precise it is: a quicker or more accurate hand has a smaller b; a is the reaction time plus the constant overshoot. (Crossman and Goodeve's deterministic version, each correction leaving a fixed fraction λ, gives b = t/log₂(1/λ).) Numbers: E ln|Z| = −(γ + ln 2)/2, so E log₂|Z| = −0.916 and μ = log₂ 5 + 0.916 = 3.24 bits per submovement; with t = 0.25 s, b ≈ 0.25/3.24 = 0.077 s per bit. Fitting the twenty simulated conditions against log₂(2D/W) gives 0.076, and simulating ratios D/W from 2⁴ to 2²⁰ gives 0.077. Against MacKenzie's log₂(D/W + 1), the fit of chapter 1 gives 0.086: the two indices agree at D/W = 1 and differ by nearly one bit at large D/W, so MacKenzie's index spans a narrower range and the slope is steeper; the extra one is a choice of index, not a different hand.
-
Questions and entropy. Show that the best yes/no questioning for a menu with item probabilities pᵢ needs between H and H + 1 questions on average.
Solution
A strategy of yes/no questions is a binary tree with the items at its leaves, and the answers to item i form a codeword of length lᵢ (its depth); no codeword is a prefix of another, so Kraft's inequality holds: Σ 2^(−lᵢ) ≤ 1. Lower bound: with S = Σ 2^(−lᵢ) and qᵢ = 2^(−lᵢ)/S, Σ pᵢlᵢ − H = Σ pᵢ log₂(pᵢ/2^(−lᵢ)) = Σ pᵢ log₂(pᵢ/qᵢ) − log₂ S ≥ 0, since the relative entropy is non-negative (Gibbs's inequality) and S ≤ 1. Upper bound: the lengths lᵢ = ⌈log₂(1/pᵢ)⌉ satisfy Σ 2^(−lᵢ) ≤ Σ pᵢ = 1, so a prefix code, and hence a questioning strategy, with those lengths exists; its mean is Σ pᵢ⌈log₂(1/pᵢ)⌉ < Σ pᵢ(log₂(1/pᵢ) + 1) = H + 1. The best strategy (Huffman's) is no worse than this one and no better than the bound, so H ≤ L* < H + 1. For chapter 2's menu, p = (0.70, 0.10, 0.10, 0.05, 0.05): H = 1.46 bits, the Huffman mean is 1.6 questions, and the lengths ⌈log₂(1/pᵢ)⌉ = (1, 4, 4, 5, 5) give 2.0, all inside [1.46, 2.46).
-
Sample size. Derive n ≈ 16σ²/δ² per arm for α = 0.05 and power 0.8, and the sample size for a 5% lift on a 5% conversion rate.
Solution
With n users per arm and per-user variance σ², each arm's mean has variance σ²/n, and the independent arms' variances add, so the estimated difference d̂ is approximately normal with mean δ and SE = σ√(2/n). The test rejects when d̂/SE > z₀.₉₇₅ = 1.96 (the opposite tail contributes negligibly under the alternative). Power is P(d̂ > 1.96 SE) = Φ(δ/SE − 1.96); setting it to 0.8 = Φ(0.8416) gives δ/SE = 1.96 + 0.8416 = 2.8016, so δ² = 2.8016² · 2σ²/n and
n = (1.96 + 0.8416)² · 2σ²/δ² = 15.70 σ²/δ² ≈ 16σ²/δ².
For a conversion rate p = 0.05, σ² = p(1 − p) = 0.0475, and a 5% relative lift is δ = 0.05 × 0.05 = 0.0025, so n = 15.70 × 0.0475/0.0025² = 119,303 users per arm, about 239,000 in all; the rule of 16 gives 121,600. (Using the treated arm's own variance, 0.0525 × 0.9475, instead of the baseline's for both arms gives 122,121.) Our simulation at n = 119,302 found the lift in 78.9% of 2,000 experiments.
-
CUPED. Prove that CUPED's estimator is unbiased and that its variance is (1 − ρ²) times the plain one, for the optimal θ.
Solution
The estimator is Δ̂_cv = (Ȳ_T − Ȳ_C) − θ(X̄_T − X̄_C), where X is measured before randomization. Because assignment is independent of X, both arms draw X from the same distribution, so E(X̄_T − X̄_C) = 0 and E Δ̂_cv = E(Ȳ_T − Ȳ_C) = Δ for every fixed θ: the adjustment cannot move the expected effect. (If X could be changed by the treatment, E(X̄_T − X̄_C) ≠ 0 and the adjustment would subtract part of the effect, hence the rule.) For the variance, each arm contributes Var(Y − θX)/n, and Var(Y − θX) = Var Y − 2θ Cov(X, Y) + θ² Var X, a parabola in θ with its minimum where the derivative −2 Cov(X, Y) + 2θ Var X vanishes: θ* = Cov(X, Y)/Var X, the regression slope. Substituting, Var(Y − θ*X) = Var Y − Cov(X, Y)²/Var X = Var Y·(1 − ρ²) with ρ = Cov(X, Y)/√(Var X Var Y), and the arms' variances add as before, so Var Δ̂_cv = (1 − ρ²) Var(Ȳ_T − Ȳ_C). In practice θ is estimated from the pooled data; the estimator is then unbiased up to a term of order 1/n, and its variance approaches the same limit. Our simulation measured ratios of 0.90, 0.74, 0.50 and 0.19 against the theory's 0.91, 0.75, 0.51 and 0.19 at ρ = 0.3, 0.5, 0.7 and 0.9.
-
Build. Simulate daily peeking with a Bonferroni correction over 30 looks, and compare its power with the mixture SPRT.
Solution
Solution notes. Add
bonferroni(days=30, per_day=1000, p=0.05, lift=0.0, alpha=0.05, trials=4000, seed=2)toexperiments.py, generating the two arms exactly asmsprtdoes (the same calls ondefault_rng(seed), so the same seed gives the same traffic); each day, compute the pooled z ofpeekingon the cumulative counts and stop at the first |z| > Φ⁻¹(1 − α/(2 · days)) = 3.14, the two-sided threshold for α/30 = 0.0017 per look. By the union bound the chance of any false rejection over the 30 looks is at most 5%, and it is lower because the looks share data. A run on the same 4,000 experiments as chapter 9 gives 1.75% false positives with no effect, against 0.4% and 1.2% for the two mixtures, and for a real 10% lift a power of 44% within 30 days (median stop day 18), between the mixture tuned to 5% lifts (39%, day 22) and the one tuned to 10% lifts (51%, day 18); all three are far below the 80% of a single look on day 30. The comparison is fair only up to day 30: Bonferroni must fix the number of looks in advance and cannot continue, while the mixture SPRT stays valid however long it runs. In z units the mixtures' boundaries are 9.90, 4.05 and 3.27 on days 1, 10 and 30 (τ for 5% lifts) and 5.47, 3.17 and 3.04 (τ for 10% lifts), against Bonferroni's flat 3.14. Group-sequential boundaries (Pocock's, O'Brien and Fleming's) spend α across a fixed schedule of looks more efficiently than Bonferroni, and are the natural next comparison; add each as a cached item incompute.pyand a test that the null rejection rate stays below 0.05. -
★ Research. An always-valid sequential test for experiments with interference.
Discussion. Open. The mixture SPRT is valid because, under the null, the likelihood ratio built from independent users' outcomes is a non-negative martingale, and Ville's inequality bounds its supremum. Interference breaks each step: a user's outcome depends on others' assignments, so outcomes are not independent; "no effect" has several meanings (no direct effect, no spillover, no effect of the global launch), and the quantity an A/B difference estimates is not the effect of launching to everyone, as chapter 13's marketplace showed (+5.4 points against +0.2). One part is easy: under Fisher's sharp null that no assignment changes anyone's outcome, interference cannot exist, and a test martingale built from the randomization itself is valid however often it is checked. The open part is everything else: confidence sequences for the global effect under a model of interference, valid at every look; designs (clusters, switchbacks) that keep power when the clusters themselves arrive sequentially or interact weakly; and bounds on the bias when the interference model is wrong. A good partial answer would state an interference model (for example, exposure through a known graph or bounded carry-over in time), construct an always-valid test or confidence sequence for a stated estimand under it, prove its error rate, and measure its power against a fixed-horizon cluster-randomized test on a simulated marketplace such as chapter 13's.
Notes and sources
Glossary
- index of difficulty, Fitts's law, throughput — log₂(D/W + 1) bits; MT = a + b·ID; 1/b, bits per second.
- submovement, steering law — one corrected piece of an aimed movement; T = a + b·A/W for paths through tunnels.
- Hick–Hyman law, entropy of a choice — decision time linear in log₂(n + 1), or in H for unequal probabilities.
- GOMS, keystroke-level model (KLM), operator (K, P, B, H, M) — goals, operators, methods and selection rules; predicting a task's time by adding operator times.
- response-time thresholds, input latency — 0.1, 1 and 10 s; the delay from an input to its effect on screen.
- just-noticeable difference, Weber fraction, Weber–Fechner law — the smallest detectable change; its ratio to the stimulus; sensation as the logarithm of stimulus.
- preattentive feature, conjunction search, change blindness — seen in parallel; found item by item; changes missed across a blank.
- cone, metamer, CIE XYZ, sRGB, transfer curve (gamma), linear light — the eye's three sensors; spectra that look alike; the standard observer; the web's colour space; code values to light; values proportional to light.
- CIELAB, OKLab, perceptual distance — spaces in which distance approximates visible difference.
- protanopia, deuteranopia, tritanopia — missing long, medium or short cones.
- relative luminance, contrast ratio — 0.2126R + 0.7152G + 0.0722B in linear light; (L₁ + 0.05)/(L₂ + 0.05).
- outline, Bézier curve, rasterization, antialiasing, hinting, subpixel rendering, x-height — how a glyph becomes pixels people can read.
- screen reader, switch access, magnification, voice control, accessible name — assistive technology and what it needs from software.
- target size, universal design, curb-cut effect, POUR — WCAG 2.2's 24 and 44 CSS pixels; design for the widest range; perceivable, operable, understandable, robust.
- heuristic evaluation, think-aloud study, Nielsen–Landauer model — inspection by experts; watching users; 1 − (1 − L)ⁿ.
- randomized controlled trial, A/B test, A/A test — assignment by a coin; two versions; two identical versions.
- two-proportion z-test, pooled rate, standard error, p-value — the standard test for conversion rates.
- false positive (α), false negative (β), power, sample size — the two errors; 1 − β; n ≈ 16σ²/δ² per arm.
- peeking, optional stopping, law of the iterated logarithm — stopping at the first significant look; why a walk crosses any fixed line.
- sequential probability ratio test, mixture SPRT, Ville's inequality, always-valid p-value — tests safe to read at every look.
- CUPED, covariate, stratification, regression adjustment — removing variance the past explains.
- multiple testing, Bonferroni correction, false discovery rate, Benjamini–Hochberg — many metrics, and two ways to correct for them.
- sample-ratio mismatch (SRM), Simpson's paradox, novelty and primacy effects, Twyman's law — pitfalls of experiments at scale.
- multi-armed bandit, Thompson sampling, regret — shifting traffic while learning; conversions lost against the best arm.
- north-star metric, driver metric, guardrail, overall evaluation criterion (OEC) — what an experiment counts.
- Goodhart's law, reward hacking, dark pattern — a measure made a target; designs that trick people.
- interference, cluster randomization, switchback — units that affect each other; randomizing groups or time slots.
- surrogate index, holdout — predicting long-term outcomes; users kept on the old product.
- randomized response, local differential privacy, ε — deniable answers; the privacy loss of one answer.
- computational rationality — a user modelled as an agent optimizing under perceptual and memory limits.
Sources
- D. Norman, The Design of Everyday Things (revised edn, 2013); S. Card, T. Moran and A. Newell, The Psychology of Human-Computer Interaction (1983); B. Shneiderman et al., Designing the User Interface (6th edn, 2016); I. S. MacKenzie, Human-Computer Interaction: An Empirical Research Perspective (2013); S. Krug, Don't Make Me Think (3rd edn, 2014); R. Kohavi, D. Tang and Y. Xu, Trustworthy Online Controlled Experiments (2020).
- D. Engelbart and W. English, "A research center for augmenting human intellect", AFIPS Fall Joint Computer Conference 1968.
- P. Fitts, "The information capacity of the human motor system in controlling the amplitude of movement", Journal of Experimental Psychology 1954; I. S. MacKenzie, "Fitts' law as a research and design tool in human-computer interaction", Human-Computer Interaction 1992; D. Meyer, R. Abrams, S. Kornblum, C. Wright and J. Smith, "Optimality in human motor performance: ideal control of rapid aimed movements", Psychological Review 1988; J. Accot and S. Zhai, "Beyond Fitts' law: models for trajectory-based HCI tasks", CHI 1997; R. W. Soukoreff and I. S. MacKenzie, "Towards a standard for pointing device evaluation", International Journal of Human-Computer Studies 2004.
- W. Hick, "On the rate of gain of information", Quarterly Journal of Experimental Psychology 1952; R. Hyman, "Stimulus information as a determinant of reaction time", Journal of Experimental Psychology 1953.
- S. Card, T. Moran and A. Newell, "The keystroke-level model for user performance time with interactive systems", Communications of the ACM 1980; D. Kieras, Using the Keystroke-Level Model to Estimate Execution Times (University of Michigan, 2001).
- R. Miller, "Response time in man-computer conversational transactions", AFIPS Fall Joint Computer Conference 1968; S. Card, G. Robertson and J. Mackinlay, "The information visualizer, an information workspace", CHI 1991; J. Nielsen, Usability Engineering (1993); A. Ng, J. Lepinski, D. Wigdor, S. Sanders and P. Dietz, "Designing for low-latency direct-touch input", UIST 2012; A. Treisman and G. Gelade, "A feature-integration theory of attention", Cognitive Psychology 1980; R. Rensink, J. K. O'Regan and J. Clark, "To see or not to see: the need for attention to perceive changes in scenes", Psychological Science 1997.
- B. Ottosson, "A perceptual color space for image processing" (2020); G. Machado, M. Oliveira and L. Fernandes, "A physiologically-based model for simulation of color vision deficiency", IEEE Transactions on Visualization and Computer Graphics 2009; IEC 61966-2-1 (sRGB); W3C, Web Content Accessibility Guidelines (WCAG) 2.2 (2023).
- R. Bringhurst, The Elements of Typographic Style (1992).
- World Health Organization, Global Report on Health Equity for Persons with Disabilities (2022).
- J. Nielsen and R. Molich, "Heuristic evaluation of user interfaces", CHI 1990; J. Nielsen, "Enhancing the explanatory power of usability heuristics", CHI 1994; J. Nielsen and T. Landauer, "A mathematical model of the finding of usability problems", INTERCHI 1993; C. Lewis, "Using the 'thinking-aloud' method in cognitive interface design", IBM Research Report RC 9265, 1982; K. A. Ericsson and H. Simon, Protocol Analysis: Verbal Reports as Data (1984).
- R. A. Fisher, The Design of Experiments (1935); R. Kohavi, R. Longbotham, D. Sommerfield and R. Henne, "Controlled experiments on the web: survey and practical guide", Data Mining and Knowledge Discovery 2009; A. Gelman and J. Carlin, "Beyond power calculations: assessing type S (sign) and type M (magnitude) errors", Perspectives on Psychological Science 2014.
- A. Wald, Sequential Analysis (1947); H. Robbins, "Statistical methods related to the law of the iterated logarithm", Annals of Mathematical Statistics 1970; J. Ville, Étude critique de la notion de collectif (1939); R. Johari, P. Koomen, L. Pekelis and D. Walsh, "Peeking at A/B tests: why it matters, and what to do about it", KDD 2017.
- A. Deng, Y. Xu, R. Kohavi and T. Walker, "Improving the sensitivity of online controlled experiments by utilizing pre-experiment data", WSDM 2013; W. Lin, "Agnostic notes on regression adjustments to experimental data: reexamining Freedman's critique", Annals of Applied Statistics 2013.
- Y. Benjamini and Y. Hochberg, "Controlling the false discovery rate: a practical and powerful approach to multiple testing", Journal of the Royal Statistical Society B 1995; E. Simpson, "The interpretation of interaction in contingency tables", Journal of the Royal Statistical Society B 1951.
- W. Thompson, "On the likelihood that one unknown probability exceeds another in view of the evidence of two samples", Biometrika 1933; M. Strathern, "'Improving ratings': audit in the British University system", European Review 1997; A. Kramer, J. Guillory and J. Hancock, "Experimental evidence of massive-scale emotional contagion through social networks", PNAS 2014; National Commission for the Protection of Human Subjects, The Belmont Report (1979).
- J. Ugander, B. Karrer, L. Backstrom and J. Kleinberg, "Graph cluster randomization: network exposure to multiple universes", KDD 2013; S. Athey, R. Chetty, G. Imbens and H. Kang, "The surrogate index: combining short-term proxies to estimate long-term treatment effects more rapidly and precisely", NBER working paper, 2019.
- S. Warner, "Randomized response: a survey technique for eliminating evasive answer bias", Journal of the American Statistical Association 1965; Ú. Erlingsson, V. Pihur and A. Korolova, "RAPPOR: randomized aggregatable privacy-preserving ordinal response", CCS 2014.
About this partfrom its README
Part 44 of a sixty-one-part course in computer science (see the series plan and the syllabus), the fifth and last part of Act VIII, Building Software. Software is used by people, and both the people and the product can be measured. Fitts's law falls out of Shannon's channel capacity, Hick's law is the entropy of a choice, perception has thresholds and colour has formulas, which we turn on this series' own palette. Where intuition runs out, industry runs controlled experiments: we derive the A/B test and its power, show why checking it every morning breaks it, and repair it with a sequential test and with CUPED.
The instruments are in explainer/cs/people/ (tested in tests/test_cs44_people.py):
hci.py: an aimed movement as a sequence of corrected submovements, each landing with an error proportional to the distance it covers, and a Fitts experiment on twenty conditions with a least-squares fit; the same target at the screen edge; a chooser who halves the candidates (Hick's n + 1 possibilities) and the Huffman mean number of yes/no questions for a skewed menu (Hyman); the keystroke-level model with operator times from Card, Moran and Newell (1980), except B (a mouse-button press), which comes from Kieras's later KLM guide, and four methods for two tasks; the Nielsen–Landauer curve 1 − (1 − L)ⁿ, and the same with problem visibilities drawn from a Beta distribution.colour.py: sRGB's transfer curve both ways, CIE XYZ and CIELAB, Ottosson's OKLab, relative luminance and the WCAG contrast ratio, colour-vision deficiency simulated with the matrices of Machado, Oliveira and Fernandes (2009) in linear light; a report on this series' palette (each colour under three deficiencies, the closest pairs in OKLab, contrast on the background); a grey ramp in code values against light; checks against published values.experiments.py: the two-proportion z-test; sample size and simulated power; daily peeking at A/A tests; the mixture sequential probability ratio test; CUPED on synthetic users; twenty null metrics, uncorrected and with Benjamini–Hochberg; a sample-ratio-mismatch check by χ²; Simpson's paradox; Thompson sampling against a 50/50 split; a marketplace with limited supply; Warner's randomized response.
Chapter notes
- Hook. San Francisco, 9 December 1968: Engelbart's NLS demo from SRI, with a mouse and pointer (Engelbart and English, 1964), hypertext, two people editing one document live, and video of a colleague thirty miles away. The ideas reach ordinary desks: the Xerox Alto (1973), Jobs's visit to PARC (1979), the Macintosh (1984), Windows 1.0 (1985), the web (1991), multi-touch phones (2007). Two kinds of measurement previewed: simulated pointing falls on Fitts's line (R² = 0.99), and an A/A test checked daily for a month declares a winner 28% of the time against the promised 5%.
- 1. Pointing is a channel. Fitts's reciprocal tapping (1954): only the ratio D/W matters, logarithmically. Shannon's C = B log₂(1 + S/N) (Part 28) becomes the index of difficulty ID = log₂(D/W + 1) bits (MacKenzie's form, 1992, never negative) and MT = a + b·ID, with 1/b a throughput. Why a logarithm: Meyer et al.'s submovements (1988), each shrinking the remaining distance by a roughly constant factor. Our simulated hand on twenty targets (D from 64 to 1024 px, W from 8 to 64 px): a = 0.333 s, b = 0.086 s per bit, R² = 0.994, a throughput of 11.6 bits per second (people with a mouse manage a few bits per second, Soukoreff and MacKenzie 2004). Infinitely deep targets: the same target takes 0.77 s in the middle of the screen and 0.40 s at the edge, hence the Macintosh's single menu bar and the corners. The steering law (Accot and Zhai, 1997), T = a + b·A/W, linear rather than logarithmic: a cascading menu is a tunnel.
- 2. Choosing, and predicting a task's time. Hick's lamps (1952) and the n + 1 that counts "no lamp"; a chooser who halves the candidates (binary search, Part 16) finds one of 7 lamps or none in log₂ 8 = 3 comparisons; simulated for one to ten lamps, a = 0.200 s, b = 0.153 s per bit, R² = 0.999. Hyman (1953): the entropy, not the count. A menu chosen with probabilities 0.70, 0.10, 0.10, 0.05, 0.05 carries H = 1.46 bits against log₂ 5 = 2.32 for five equal choices, and the best yes/no questioning (a Huffman code, AI, Built Part 1) needs 0.7 × 1 + 0.3 × 3 = 1.6 questions on average. Where the law stops: scanning an unfamiliar list is a linear search, and practice flattens the slope. GOMS (Card, Moran and Newell, The Psychology of Human-Computer Interaction, 1983): goals, methods of operators, selection rules. The keystroke-level model: K 0.28 s, P 1.10, B 0.10, H 0.40, M 1.35 (Card, Moran and Newell 1980; B from Kieras's later KLM guide). Deleting a file through a menu, HMPBMPB, 5.5 s; with a shortcut, HMPBHMKK (from the same starting position), 5.26 s; renaming through a dialog 9.47 s, inline with F2 8.85 s. The M blocks dominate: a faster design asks for fewer decisions, not fewer keys.
- 3. Perception and its thresholds. 0.1, 1 and 10 seconds (Miller 1968; Card, Robertson and Mackinlay 1991; Nielsen, Usability Engineering, 1993): instantaneous, flow of thought kept, attention kept, attention lost. Input latency: Ng et al. (Microsoft Research, 2012) found people dragging on a touch screen notice delays of a few milliseconds; an input crosses sensor, operating system, application, rendering, compositing and display, and each stage that waits for the next frame can add 16.7 ms at 60 Hz (Part 42). Weber's fraction ΔI/I = k (1834) and Fechner's S = c log(I/I₀) (1860): +0.1 on a bar of 1 is +10%, on a bar of 4 only +2.5%. What pops out: colour and orientation are found in parallel, a red and tilted line among red upright and blue tilted ones item by item (Treisman and Gelade's feature integration theory, 1980). Change blindness (Rensink, O'Regan and Clark, 1997): six dashboard numbers behind a flicker, and the errors tile going from 17 to 71 unseen.
- 4. Colour. Three cones, metamers, CIE XYZ (1931), sRGB (HP and Microsoft, 1996). Code values are not light:
under the transfer curve (c + 0.055)/1.055 raised to 2.4, code 128 (#808080) emits 21.6% of white's light, and half
of white's light is #bcbcbc; equal code steps are roughly equal steps of lightness (Weber and Fechner again), so
blending and lighting must happen in linear light (Part 51). CIELAB (1976) and OKLab (Ottosson, 2020), with this
series' six colours plotted in OKLab's a–b plane; our conversions give white L = 100.0 in CIELAB and 1.000 in OKLab,
and sRGB red (0.628, 0.225, 0.126), the published value. The palette under simulated deficiency (Machado, Oliveira
and Fernandes, 2009), closest pair by OKLab distance: typical vision
data–lambda0.102; protanopiahere–true0.066; deuteranopiafalse–kernel0.014; tritanopiadata–true0.066 (below 0.08 counts as easily confused). The honest finding: under deuteranopia this series' red for false and orange for the kernel are nearly the same colour. Contrast on the background:data7.1,here12.1,true9.3,false5.9,lambda6.1,kernel6.7, all above WCAG's 4.5 for text and three above 7; a two-series chart separated by red and orange becomes one series under deuteranopia, and survives with shapes and direct labels. Never colour alone. - 5. Text on screens. A glyph is an outline of Bézier curves (TrueType, Apple, 1991, quadratic; PostScript and OpenType CFF, cubic); a pixel is lit when its centre is inside, by counting crossings of a ray (Part 22's orientation test; Part 51 rasterizes triangles the same way). "Job" in DejaVu Serif rasterized by FreeType at 8, 12, 16 and 24 px: at 8 px the whole word is 23 × 11 pixels; one bit per pixel gives 2 levels, antialiasing 41, 66, 80 and 111 grey levels. Hinting: three equal stems 1.4 px wide land as coverages (0.7, 0.7), (1.0, 0.4) and (0.3, 1.0, 0.1), and snapped to whole pixels they are equal again; TrueType's hinting programs run on a small stack machine. Subpixel rendering: a one-pixel stem starting a third of the way in is two dim greys as whole pixels, and placed to a third of a pixel with stripes; ClearType in Windows XP (2001); Apple turned it off in macOS in 2018. Readable text: 93 characters a line with tight spacing against 60 with spacing 1.5 (Bringhurst: 45 to 75, 66 ideal; WCAG 1.4.8: at most 80, spacing at least 1.5); x-height; contrast 4.5 to 1.
- 6. Accessibility. About 1.3 billion people, 16% of the world, live with significant disability (WHO); permanent, temporary and situational versions of each need, after Microsoft's Inclusive Design toolkit. Screen readers, switch access, magnification (text to 200%, reflow at 320 CSS pixels) and voice control (the visible label in the accessible name, 2.5.3). Motor accessibility with chapter 1's fit, MT = 0.33 + 0.086 log₂(D/W + 1), at a reach of 480 px: a 16 px target has ID 4.95 and a predicted 759 ms, 24 px 4.39 and 710 ms, 44 px 3.57 and 640 ms; WCAG 2.2's 24 × 24 CSS pixels at AA (2.5.8), 44 × 44 at AAA (2.5.5), and a single-pointer alternative to dragging (2.5.7). Cognitive accessibility: consistent navigation (3.2.3), adjustable time limits (2.2.1), sign-in without a memory or puzzle test (3.3.8), captions with sounds (1.2.2). Universal design (Ronald Mace) and the curb-cut effect; WCAG's four principles, perceivable, operable, understandable, robust.
- 7. Evaluating usability. Nielsen's ten heuristics (1994) and heuristic evaluation (Nielsen and Molich, 1990); thinking aloud (Clayton Lewis at IBM, 1982, from Ericsson and Simon's verbal reports), on an illustrative session. Nielsen and Landauer's model (1993), found = 1 − (1 − L)ⁿ with L = 0.31: one user finds 31% of the problems, two 52%, three 67%, four 77%, five 84% (the chapter's title asks the famous "five users find 85%?"). With visibility varying from problem to problem (a Beta distribution with the same mean), five users find 71%, and reaching 84% takes 11 users. A problem that hits one user in twenty is found by five users with probability 1 − 0.95⁵ = 23%; one round of fifteen would find 99.6% of today's problems, but Nielsen's advice (2000) is three rounds of five, fixing in between.
- 8. The A/B test. A randomized controlled trial (Fisher, 1935): a coin, not a person, assigns users, so the arms differ only by chance in every trait, measured or not (Part 20's concentration). The two-proportion z-test derived: pooled rate under the null, SE = √(p̂(1 − p̂)(1/n_A + 1/n_B)), p = 2(1 − Φ(|z|)); 500 against 560 conversions out of 10,000 each (pooled 5.30%, SE 0.317 points) is a 12% lift with z = 1.89 and p = 0.058, not significant. Two errors: α = 5%, and β = 20% when δ sits 1.96 + 0.84 standard errors out. Sample size n ≈ 16σ²/δ² per arm, the constant (1.96 + 0.84)² × 2 = 15.7; on a 5% conversion rate, relative lifts of 1, 2, 5, 10 and 20% need 2,982,574, 745,643, 119,303, 29,826 and 7,456 users per arm (the rule of 16 says 3,040,000, 760,000, 121,600, 30,400 and 7,600). Checked on 2,000 simulated experiments: at n = 119,302 the power is 0.79 (78.9%), at half that 0.50 (theory Φ(2.80/√2 − 1.96) = 0.51); an underpowered test that reaches significance overstates the effect (Gelman and Carlin, 2014).
- 9. Looking too often. An A/A test, 1,000 users a day in each arm, 5% converting, z-tested every morning: of six p-value paths, one falls below 0.05, on the last morning. Over 4,000 simulated A/A experiments stopped at the first p < 0.05: 5% on day 1, 17% after a week, 23% after two weeks, 28% (28.1%) by day 30; the same experiments looked at once on day 30 give 4.2%. Why: with no effect z is a scaled random walk, and by the law of the iterated logarithm (Khinchin, 1924) its peaks keep reaching √(2 log log n); thirty independent tests would give 79%, overlapping looks give 28%. The fix: Wald's sequential test, averaged over plausible effects by Robbins (1970), Λₙ against 1/α = 20; a martingale with mean 1 under the null, so by Ville's inequality (1939) P(supₙ Λₙ ≥ 1/α) ≤ α; in z units its boundary starts high and comes down; always-valid p-values (Johari, Pekelis and Walsh). On the same traffic: false positives 28.1% for daily z-tests, 4.2% for one look, 0.4% for the mixture tuned to 5% lifts and 1.2% tuned to 10% lifts; for a real 10% lift within 30 days, power 39% (median stop day 22) and 51% (day 18), against 80% by design for a fixed test that needs 29,826 users per arm, the whole 30 days looked at once.
- 10. Less noise, same truth. CUPED (Deng, Xu, Kohavi and Walker, 2013): Y_cv = Y − θ(X − X̄) with X the user's metric in the month before. Derived: θ* = Cov(X, Y)/Var X, the regression slope, and Var(Y − θ*X) = Var Y·(1 − ρ²); unbiased because X is measured before randomization. On 20,000 users per arm, 2,000 repeated experiments per correlation, the variance ratio is 1.00, 0.90, 0.74, 0.50 and 0.19 at ρ = 0, 0.3, 0.5, 0.7 and 0.9 (theory 1, 0.91, 0.75, 0.51, 0.19), worth ×1.0, ×1.1, ×1.3, ×2.0 and ×5.3 the users. For a true effect of 0.02 standard deviations the 95% interval is ±0.0197 without CUPED, ±0.0171 at ρ = 0.5, ±0.0141 at 0.7 (29% narrower) and ±0.0086 at 0.9 (56% narrower). Stratification by the law of total variance; regression adjustment in general, which with treatment-by-covariate terms cannot hurt precision in large samples (Lin, 2013).
- 11. Pitfalls at scale. Twenty metrics in an A/A test: P(at least one p < 0.05) = 1 − 0.95²⁰ = 64.2%, simulated 64.1%. Bonferroni's α/k, and Benjamini and Hochberg's step-up line αi/k (1995), which controls the false discovery rate: with nothing real, 5.0% of experiments make any false discovery (on four illustrative real effects among twenty, the line picks them out). Sample-ratio mismatch: 50,000 against 49,000 on a 50/50 split gives χ² = 10.1, p = 0.0015, a broken split; 50,100 against 49,900 gives χ² = 0.4, p = 0.53, chance. Simpson's paradox (1951): a redesign converting 11.2% against 10.0% on desktop and 5.8% against 3.0% on mobile, but 6.5% against 7.7% overall, because 5,200 of its 6,000 visitors were on mobile (illustrative counts). Novelty and primacy effects, read by days since first exposure. Twyman's law, with a checklist for an illustrative revenue +38%.
- 12. Bandits and metrics. Thompson sampling (1933; AI, Built Part 26): draw a plausible rate from each beta belief and show the higher. Raced over 100,000 visitors with versions converting 5.0% and 5.5% (200 repetitions, updates every 500 visitors): a 50/50 split loses about 253 conversions, Thompson sampling 48; but the split measures the difference with a standard deviation of 0.0014 (0.14 points) and the bandit 0.0066, about 5 times less precise. Bandits for optimizing, A/B tests for learning. A north-star metric, driver metrics and guardrails (load time, crashes, unsubscribes, support tickets); ship when the overall evaluation criterion improves and no guardrail regresses (Kohavi). Goodhart's law (Goodhart 1975, in Strathern's 1997 wording) and reward hacking (AI, Built Part 31); dark patterns (Brignull, 2010). Experimenting on people: Kramer, Guillory and Hancock (PNAS 2014), about 689,000 Facebook users for one week in January 2012, the editorial expression of concern, and the Belmont Report (1979).
- 13. Frontier: measuring people, carefully. Interference: 10,000 buyers and 3,000 items, treatment making buyers 6 points keener (30% against 36%); the A/B test reports +5.4 points, launching to everyone gives +0.2; with ample supply the two agree (+6.0 and +5.9). Fixes: randomize markets, cities or time slots (switchbacks), clusters of friends (Ugander et al., 2013). Effects that take years: surrogate indices (Athey, Chetty, Imbens and Kang, 2019) and long-running holdouts. Measuring without looking: Warner's randomized response (1965), truthful with probability 0.75, otherwise a coin, local differential privacy with ε = ln 7 = 1.95; on a true rate of 20%, the mean error of an honest survey against the randomized one is 3.09 against 4.76 points for 100 people, 1.01 against 1.47 for 1,000, 0.32 against 0.49 for 10,000 and 0.10 against 0.15 for 100,000, about one and a half times; RAPPOR (2014), Apple's keyboard statistics (2016), the 2020 US Census (central, not local). Models of the user: computational rationality, simulated users and language models as synthetic participants, adaptive interfaces. Four open problems and the ★ research problem.
- Outro. Recap, payoffs, practice, problems, next part.
Companion material in this repository
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Hook: Engelbart's 1968 demo (mouse, hypertext, collaborative editing); Xerox PARC and the GUI.
- Fitts's law, MT = a + b log₂(D/W + 1), derived from channel capacity (MacKenzie's form); why screen edges are infinitely deep targets; the steering law.
- Hick–Hyman: decision time grows with the entropy of the choice (callback to AI, Built 1).
- GOMS and the keystroke-level model (Card, Moran & Newell): predicting task time.
- Perception: the 0.1 s / 1 s / 10 s thresholds; input latency; Weber–Fechner and just-noticeable differences; preattentive features.
- Colour:
- XYZ, sRGB and gamma; perceptual spaces (CIELAB, OKLab);
- colour-blindness simulated on the series' own palette;
- the WCAG contrast ratio (L₁ + 0.05)/(L₂ + 0.05), derived from relative luminance.
- Text on screens: glyph rasterization (callback to Part 51), hinting, readability.
- Accessibility: assistive technology, the accessibility tree, motor and cognitive accessibility, universal design.
- Usability evaluation: Nielsen's heuristics; think-aloud studies; "five users find 85%" from 1 − (1 − p)ⁿ (Nielsen & Landauer 1993) and its caveats.
- Experiments: the A/B test as a randomized controlled trial; the two-proportion z-test, derived; power and sample size (n ≈ 16σ²/δ², derived).
- The peeking problem: checking daily multiplies the false-positive rate (simulated); sequential tests and always-valid p-values (Johari et al. 2017) fix it.
- CUPED (Deng et al. 2013): regression on the pre-period cuts variance by (1 − ρ²) (derived); stratification.
- Pitfalls at scale:
- multiple testing and false discovery rates;
- Simpson's paradox; novelty effects;
- interference in marketplaces and social graphs, and cluster randomization;
- sample-ratio-mismatch checks (χ²); Twyman's law.
- Bandits against A/B tests (callback to AI, Built 26): regret against clean inference.
- Metrics and ethics: north-star metrics; Goodhart's law (callback to AI, Built 31); dark patterns; privacy-preserving analytics. Outro.
Computed: Fitts and Hick regressions (on published data, cited, and on simulated pointing); colour conversions, contrast ratios and colour-blind views of the palette; Nielsen–Landauer curves; power calculations; peeking simulations; sequential tests; CUPED on synthetic data; SRM detection. Visuals: targets shrinking and moving under the log curve; the sRGB cube sitting inside OKLab; p-value paths wandering across 0.05 under peeking; a confidence interval shrinking under CUPED. In practice: product engineering, UX research, growth and experimentation platforms, design systems, accessibility compliance. Reading: Norman, The Design of Everyday Things; Card, Moran & Newell, The Psychology of Human-Computer Interaction; Shneiderman et al., Designing the User Interface; MacKenzie, Human-Computer Interaction: An Empirical Research Perspective; Krug, Don't Make Me Think; Kohavi, Tang & Xu, Trustworthy Online Controlled Experiments; Fitts 1954; Hick 1952; Hyman 1953; Nielsen & Landauer 1993; Deng et al. 2013; Johari et al. 2017; WCAG 2.2; Ottosson 2020.
中文讲义
本讲的中文部分(与英文版对应)。
习题与解答
-
由子运动推出菲茨定律。 设每次子运动的落点误差与它走过的距离成正比,推导菲茨定律,并说明斜率 b 由什么决定。
解答
设 dₖ 为 k 次子运动之后剩下的距离,d₀ = D。每次子运动瞄准目标中心,落点误差与它走过的距离成正比,所以 dₖ₊₁ = σ|Zₖ|·dₖ,其中 Zₖ 相互独立,σ 是手的相对精度(在我们的仪器里 σ = 0.2,Zₖ 服从标准正态分布)。当第一次出现 dₖ ≤ W/2,也就是 Σ log₂(1/(σ|Zᵢ|)) ≥ log₂(2D/W) 时,运动结束。所以每次子运动平均交付 μ = E log₂(1/(σ|Z|)) = log₂(1/σ) − E log₂|Z| 比特,而目标要求的是 log₂(2D/W) 比特;由更新定理,子运动的次数 N ≈ log₂(2D/W)/μ 加上一个常数(最后一次会越过阈值)。每次子运动用时 t,反应时间 t₀,则 MT = t₀ + t·N ≈ a + b log₂(2D/W),正是菲茨自己的形式,其中
b = t/μ,即 1/b = μ/t 比特每秒。
斜率由一次修正用多久、有多准决定:更快或更准的手,b 更小;a 是反应时间加上那个常数的越过量。(Crossman 和 Goodeve 的 确定性版本中,每次修正剩下固定的比例 λ,得到 b = t/log₂(1/λ)。)数值:E ln|Z| = −(γ + ln 2)/2,所以 E log₂|Z| = −0.916,μ = log₂ 5 + 0.916 = 3.24 比特每次子运动;t = 0.25 秒时,b ≈ 0.25/3.24 = 0.077 秒每比特。对二十个 模拟条件按 log₂(2D/W) 拟合得 0.076,对 D/W 从 2⁴ 到 2²⁰ 的模拟得 0.077。按麦肯齐(MacKenzie)的 log₂(D/W + 1) 拟合, 第一章得到 0.086:两种指数在 D/W = 1 时相同,在 D/W 很大时相差将近一比特,所以麦肯齐的指数跨度更窄、斜率更陡;多出来的 这部分来自指数的选择,而不是手不同。
-
提问与熵。 证明:对于各项概率为 pᵢ 的菜单,最好的是非提问方式平均需要的问题数在 H 和 H + 1 之间。
解答
一种是非提问策略是一棵二叉树,各项在叶子上,第 i 项得到的回答构成长度为 lᵢ(它的深度)的码字;任何码字都不是 另一个码字的前缀,所以克拉夫特不等式成立:Σ 2^(−lᵢ) ≤ 1。下界:令 S = Σ 2^(−lᵢ),qᵢ = 2^(−lᵢ)/S,则 Σ pᵢlᵢ − H = Σ pᵢ log₂(pᵢ/2^(−lᵢ)) = Σ pᵢ log₂(pᵢ/qᵢ) − log₂ S ≥ 0,因为相对熵非负(吉布斯不等式),且 S ≤ 1。上界: 长度 lᵢ = ⌈log₂(1/pᵢ)⌉ 满足 Σ 2^(−lᵢ) ≤ Σ pᵢ = 1,所以存在具有这些长度的前缀码,也就存在相应的提问策略;它的平均值为 Σ pᵢ⌈log₂(1/pᵢ)⌉ < Σ pᵢ(log₂(1/pᵢ) + 1) = H + 1。最好的策略(哈夫曼编码)不比它差,也不可能好过下界,所以 H ≤ L* < H + 1。对第二章的菜单,p = (0.70, 0.10, 0.10, 0.05, 0.05):H = 1.46 比特,哈夫曼平均 1.6 个问题,长度 ⌈log₂(1/pᵢ)⌉ = (1, 4, 4, 5, 5) 给出 2.0,都在 [1.46, 2.46) 之内。
-
样本量。 推导在 α = 0.05、功效 0.8 时每组 n ≈ 16σ²/δ²,并求在 5% 的转化率上检测 5% 的提升所需的样本量。
解答
每组 n 个用户,每个用户的方差为 σ²,每组均值的方差为 σ²/n,两组相互独立,方差相加,所以估计的差 d̂ 近似服从 均值为 δ、标准误 SE = σ√(2/n) 的正态分布。当 d̂/SE > z₀.₉₇₅ = 1.96 时拒绝(在备择假设下另一侧尾部的贡献可以忽略)。 功效为 P(d̂ > 1.96 SE) = Φ(δ/SE − 1.96);令它等于 0.8 = Φ(0.8416),得 δ/SE = 1.96 + 0.8416 = 2.8016,于是 δ² = 2.8016² · 2σ²/n,
n = (1.96 + 0.8416)² · 2σ²/δ² = 15.70 σ²/δ² ≈ 16σ²/δ²。
转化率 p = 0.05 时,σ² = p(1 − p) = 0.0475;5% 的相对提升是 δ = 0.05 × 0.05 = 0.0025,所以 n = 15.70 × 0.0475/0.0025² = 119,303 人每组,共约 239,000 人;16 法则给出 121,600。(若实验组用它自己的方差 0.0525 × 0.9475,而不是两组都用基线的方差,则得 122,121。)我们在 n = 119,302 时的模拟,在 2,000 次实验中有 78.9% 检测到了这个提升。
-
CUPED。 证明 CUPED 的估计量是无偏的,并证明在最优 θ 下它的方差是普通估计量的 (1 − ρ²) 倍。
解答
估计量为 Δ̂_cv = (Ȳ_T − Ȳ_C) − θ(X̄_T − X̄_C),其中 X 在随机分组之前测得。由于分组与 X 独立,两组的 X 来自同一 分布,所以 E(X̄_T − X̄_C) = 0,对任意固定的 θ 都有 E Δ̂_cv = E(Ȳ_T − Ȳ_C) = Δ:调整不会移动效应的期望。(如果 X 会受 处理影响,E(X̄_T − X̄_C) ≠ 0,调整就会减掉一部分效应,这就是那条规则的由来。)关于方差,每组贡献 Var(Y − θX)/n,而 Var(Y − θX) = Var Y − 2θ Cov(X, Y) + θ² Var X 是 θ 的抛物线,在导数 −2 Cov(X, Y) + 2θ Var X 为零处取最小值: θ* = Cov(X, Y)/Var X,即回归斜率。代回得 Var(Y − θ*X) = Var Y − Cov(X, Y)²/Var X = Var Y·(1 − ρ²),其中 ρ = Cov(X, Y)/√(Var X Var Y);两组方差照旧相加,所以 Var Δ̂_cv = (1 − ρ²) Var(Ȳ_T − Ȳ_C)。实践中 θ 由合并的数据估计; 这时估计量的偏差是 1/n 阶的,方差趋于同一极限。我们的模拟在 ρ = 0.3、0.5、0.7、0.9 时测得的比值为 0.90、0.74、0.50、 0.19,理论值为 0.91、0.75、0.51、0.19。
-
动手。 模拟对 30 次查看做 Bonferroni 校正的每日偷看,并把它的功效与混合序贯概率比检验(mSPRT)比较。
解答
解答要点。 在
experiments.py里加上bonferroni(days=30, per_day=1000, p=0.05, lift=0.0, alpha=0.05, trials=4000, seed=2),像msprt那样生成两组数据(对default_rng(seed)做同样的调用,所以同一个种子给出同样的流量);每天用peeking的合并 z 检验处理累计计数,第一次出现 |z| > Φ⁻¹(1 − α/(2 · days)) = 3.14 时停止,这是每次查看 α/30 = 0.0017 的双侧阈值。由并集上界,30 次查看中出现任何错误拒绝的概率至多为 5%,又因为各次查看共用数据,实际更低。在与第九章相同的 4,000 次实验上运行:没有效应时假阳性为 1.75%,两种混合检验为 0.4% 和 1.2%;真实提升 10% 时,30 天内的功效为 44% (停止日的中位数为第 18 天),介于针对 5% 提升的混合检验(39%,第 22 天)和针对 10% 提升的混合检验(51%,第 18 天) 之间;三者都远低于第 30 天只看一次的 80%。这个比较只在第 30 天之前公平:Bonferroni 必须事先定下查看次数,不能继续;而 mSPRT 不论运行多久都有效。以 z 为单位,混合检验的边界在第 1、10、30 天为 9.90、4.05、3.27(τ 针对 5% 的提升)和 5.47、 3.17、3.04(τ 针对 10% 的提升),而 Bonferroni 是平直的 3.14。成组序贯边界(Pocock 的、O'Brien 和 Fleming 的)按固定的 查看计划分配 α,比 Bonferroni 更高效,是下一个自然的比较对象;把每一种都作为compute.py里的缓存项,并加上一个检验, 确保零假设下的拒绝率低于 0.05。 -
★ 研究。 求一个适用于存在干扰的实验、始终有效的序贯检验。
讨论。 尚未解决。mSPRT 之所以有效,是因为在零假设下,由相互独立的用户结果构造的似然比是一个非负鞅,维尔不等式约束了 它的上确界。干扰破坏了每一步:一个用户的结果取决于别人的分组,所以结果不再独立;“没有效应”有好几种含义(没有直接效应、 没有溢出效应、全面上线没有效应),而 A/B 差值估计的量并不是全面上线的效应,第十三章的市场就说明了这一点(+5.4 个百分点 对 +0.2)。有一部分是容易的:在费希尔的尖锐零假设(任何分组都不改变任何人的结果)下,干扰不可能存在,由随机化本身构造的 检验鞅不论查看多少次都有效。其余都是开放的:在某个干扰模型下、对全局效应、每次查看都有效的置信序列;当聚类本身按顺序 到来、或彼此弱相互作用时仍保有功效的设计(聚类、轮换);以及干扰模型错误时偏差的界。好的部分答案应当给出一个干扰模型 (例如通过已知图的暴露,或时间上有界的延续效应),在其下为一个明确的估计量构造始终有效的检验或置信序列,证明它的错误率, 并在第十三章那样的模拟市场上,把它的功效与固定期限的聚类随机化检验比较。
Build the film
python -m videos.cs.cs44.compute # the part's numbers, into .cache/cs44
python tools/build.py cs44 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py cs44 Hook # one chapter, silent, with a contact sheet
Scenes: videos/cs/cs44. Setup: see the course page. Source of these notes: the README and the scenes' narration.
Build it
python -m videos.cs.cs44.compute
python -m unittest tests.test_cs44_people
python tools/build.py cs44