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
Statistics & Math
Machine Learning Engineer
Meta
November 29, 2026
Machine Learning Engineer
Onsite
Statistics & Math
Medium

0

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
Inversions
Linearity of expectation
Kendall tau
Ranking metrics
Null distribution
How to Approach This
  1. Define your hypotheses (H0 and H1) clearly before performing any test.
  2. Calculate required sample size BEFORE running an experiment, using power analysis.
  3. Remember the Central Limit Theorem: sample means become approximately normal with large n.
  4. Watch for Simpson's paradox. Always segment data by key dimensions.
  5. 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 Questions
Sample Answer
Clarify

There are n=20n=20 posts with a true ideal order. A random ranker produces a uniformly random permutation. An inversion is a pair (i,j)(i,j) ranked in the opposite order to the ideal; there are $\binom{20}...

Approach

Write the inversion count I=∑i<jXijI=\sum_{i<j}X_{ij} with XijX_{ij} indicating that pair is flipped. By symmetry each P(Xij=1)=1/2P(X_{ij}=1)=1/2. Indicators sharing an element are correlated, which matters for the va...


Submit Your Answer
Markdown supported