Expected Out of Order Pairs When Ranking Twenty Posts at Random
Last updated: November 29, 2026
Quick Overview
A baseline Feed ranker orders 20 candidate posts uniformly at random. Find the mean and standard deviation of the number of pairs out of order relative to the ideal ranking, and use it to judge a model with 40 inversions.
Meta
November 29, 20260
0
0 solved
A baseline Feed ranker orders 20 candidate posts uniformly at random. Find the mean and standard deviation of the number of pairs out of order relative to the ideal ranking, and use it to judge a model with 40 inversions.
Ranking evaluation at Meta often uses pairwise metrics, and engineers should know what a random ranker scores so they can judge whether a model is meaningfully better. The interviewer checks linearity of expectation over pairs, a variance result or derivation sketch, and the link to Kendall's tau.
What the Interviewer Expects
- Defines inversions over all C(n,2) pairs
- Uses indicators with probability 1/2 to get n(n-1)/4 = 95
- States the variance n(n-1)(2n+5)/72 and computes sd of about 15.4
- Computes a z-score and Kendall tau for 40 inversions
- Notes that inversions on the top positions matter more in practice
Key Topics to Cover
How to Approach This
- Define your hypotheses (H0 and H1) clearly before performing any test.
- Calculate required sample size BEFORE running an experiment, using power analysis.
- Remember the Central Limit Theorem: sample means become approximately normal with large n.
- Watch for Simpson's paradox. Always segment data by key dimensions.
- Distinguish between statistical significance and practical significance.
Possible Follow-up Questions
- Why are the pair indicators not independent, and how does that enter the variance?
- Convert 40 inversions to Kendall's tau.
- Why might you prefer NDCG over inversion count for Feed?
- How would you compute inversions in O(n log n)?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Browse Statistics QuestionsSample Answer
Clarify
There are posts with a true ideal order. A random ranker produces a uniformly random permutation. An inversion is a pair ranked in the opposite order to the ideal; there are $\binom{20}...
Approach
Write the inversion count with indicating that pair is flipped. By symmetry each . Indicators sharing an element are correlated, which matters for the va...