Here are eight users, the same eight as in the worked example. x is each user's sessions in the week before the test, and y their sessions in the test's first week.
import numpy as np# sessions, the week beforex = np.array([2.0, 4, 6, 8, 4, 6, 8, 10])# sessions, the test weeky = np.array([2.0, 4, 5, 7, 6, 8, 7, 9])print(np.corrcoef(x, y)[0, 1].round(3))
Predict
How strongly do the eight users' x and y move together?
Pick one to see what it prints.
That's the correlation of x and y: 1 for points on a rising straight line, 0 for no straight-line link at all. The correlation in a sample is written r. It estimates the true one, written ρ (rho). 0.866 is high. Here are the eight users, with the straight line that fits them best.
Pick an answer above to see the rest
Predict
The line expects 6 sessions from both users at x = 6. The treatment user did 8 and the control user 5. What does CUPED keep for each?
C4 and T3 both sit at (8, 7). The two users at x = 6 show their distance from the line.
The line is the least-squares line: the one that makes the sum of the squared vertical distances to the points as small as possible. It rises 0.75 test-week sessions for each extra session the week before.
The distances from the line are the surprises. The rest of each user's y, the part on the line, was predictable from x.
In the editor, write correlation(x, y) from sums, the 0.866 that np.corrcoef printed.
Pick an answer above to see the rest
Instructions
1
Write correlation(x, y): the sum of products of the distances from the means, over the square root of the two sums of squares.