Why it's unbiased
An impression at position is clicked with chance . Divide by , and is what's left:
is the expected value: the average over many impressions. That holds at every position, so any mix of positions averages to .
It needs one condition. Every position the item was shown at must have . A position nobody ever looks at tells you nothing, and no weight can fix that.
Here's what 1,000 simulated logs give, each built like the practice test's:
| Estimator | Code | Expected | Mean of 1,000 logs | Spread (sd) |
|---|---|---|---|---|
| Raw click-through rate | mean(c) | 0.161 | 0.161 | 0.0008 |
| IPS | mean(c / p) | 0.300 | 0.300 | 0.0019 |
| Multiplied by propensity | mean(c * p) | 0.114 | 0.114 | 0.0006 |
IPS landed within 0.01 of 0.3 in all 1,000 logs. It pays for that with a spread a bit over twice as wide as raw click-through rate's. That's the variance question under the follow-ups.
The same weight fixes offline scoring on clicks. To score a new ranker on old logs, count each logged click toward its metric, divided by the propensity of the slot where the click happened. Joachims, Swaminathan and Schnabel prove this estimate is unbiased.
A real log mixes many items. In the editor, write ips_by_item(items, clicks, positions, propensity): items[j] is the item id shown at impression j, and you return each item's IPS click rate, indexed by its id.