Skip to content
Vamshi Jandhyala

Books · The Fiddler: Solutions

Chapter 88

Can You Hack Gymnastics?

Gymnast AA has a difficulty score of 6.06.0 and gymnast BB a difficulty score of 5.05.0. Each receives an independent execution score drawn uniformly at random from 00 to 1010. What is the probability that the two gymnasts end up in the same relative order whether their two subscores are added or multiplied?

The Fiddler, Zach Wissner-Gross, August 9, 2024(original post)

Solution

Write a,ba,b for the two execution scores, each uniform on [0,10][0,10]. Adding puts AA ahead when (6+a)(5+b)=1+ab>0(6+a)-(5+b)=1+a-b>0; multiplying puts AA ahead when 6a5b>06a-5b>0. The two methods give the same order exactly when these share a sign, that is when (a,b)(a,b) lies on the same side of both lines b=a+1b=a+1 and b=65ab=\tfrac65a. Those lines cross at (5,6)(5,6), inside the square, so the only disagreement is the pair of thin slivers between them. Integrating the agreement region over the 10×1010\times10 square gives area 5776\tfrac{577}{6}, hence probability 57760096.17%.\boxed{\tfrac{577}{600}}\approx96.17\%.

The computation

Encode the agreement condition itself and integrate it: the region where both gaps are positive, plus the region where both are negative, over the 10×1010\times10 square.

import sympy as sp
a, b = sp.symbols('a b')
f1, f2 = 1 + a - b, 6 * a - 5 * b                # added gap, multiplied gap
def region(cond):                               # area where both gaps satisfy cond
    return sp.integrate(sp.Piecewise((1, cond), (0, True)), (b, 0, 10), (a, 0, 10))
agree = region((f1 > 0) & (f2 > 0)) + region((f1 < 0) & (f2 < 0))
print(sp.Rational(agree, 100))                    # 577/600

Extra Credit

Now let both difficulty scores also be independent and uniform on [0,10][0,10]. What is the probability the ranking agrees under adding and multiplying?

Solution

With all four scores random, write the difficulties dA,dBd_A,d_B and executions a,ba,b, all uniform on [0,10][0,10]. Adding and multiplying agree when (dA+a)(dB+b)(d_A+a)-(d_B+b) and dAadBbd_Aa-d_Bb share a sign. Averaging over the four-dimensional cube, the probability falls to about 0.9168.\boxed{0.9168.} It drops from the 96%96\% of the fixed-difficulty case because random difficulties make near-ties far more common, and near-ties are exactly where adding and multiplying can disagree. (There is no tidy closed form; this is the simulated value.)

The computation

Sample the four scores uniformly and measure how often the two orderings agree.

import numpy as np
rng = np.random.default_rng(0); n = 20_000_000
dA, dB, a, b = rng.random((4, n)) * 10
agree = (np.sign((dA + a) - (dB + b)) == np.sign(dA * a - dB * b)).mean()
print(agree)                                       # ~0.9168