Sunday 30 August 2026

Quant interview

Loaded dice, uniform sums, and the Sicherman relabeling

hard · Generating functions and transforms

Throughout, a "die" is a six-faced die whose faces carry values in {1,2,3,4,5,6} (part 1) or in the positive integers (part 2). Two dice are rolled independently and their values added. Encode a die by its probability (or counting) generating function A(x)=∑iaixi, where ai is the weight attached to the value i; the generating function of the sum of two independent dice is then the product of their generating functions.

1. Let two dice carry values in {1,…,6} with arbitrary probability weights a1,…,a6≥0 and b1,…,b6≥0 (each set summing to 1; the two dice need not be identical and neither need be fair). Prove that no choice of weights makes the sum S=X+Y uniformly distributed on {2,3,…,12}.

2. Now let both dice be fair (each of the six faces equally likely) but allow the six faces of each die to be labeled with arbitrary positive integers, repetitions permitted. Determine all unordered pairs of such dice whose sum has exactly the same distribution as the sum of two ordinary fair dice labeled 1,…,6. Exhibit explicitly every labeling that differs from the standard one.

Solution

Part 1: the uniform sum is impossible

Write the generating functions A(x)=∑i=16aixi,B(x)=∑j=16bjxj. By independence, the probability generating function of S=X+Y is the product A(x)B(x). A uniform law on {2,…,12} (eleven values) would require A(x)B(x)=111∑k=212xk=x211(1+x+⋯+x10)=x211·x11−1x−1.

Both dice show values ≥1, so A and B have zero constant term; factor out the smallest power: A(x)=xA~(x),B(x)=xB~(x). The product has degree 12 and each factor has degree at most 6, so both must have degree exactly 6 (equivalently a6,b6>0). Hence A~,B~ are real polynomials of degree 5, and cancelling x2 gives A~(x)B~(x)=111(1+x+⋯+x10)=111·x11−1x−1.

Here is the step a candidate misses. The roots of x11−1x−1 are the eleven 11th roots of unity except 1. Because 11 is odd, the only real solution of x11=1 is x=1, which we have removed; therefore the right-hand side has no real root at all.

But A~ has real coefficients and odd degree 5, so by the intermediate value theorem (a real polynomial of odd degree changes sign at ±∞) it must have at least one real root x0. Then x0 is a real root of the product, contradicting that the product has no real roots.

Conclusion. No weighting of two six-sided dice yields a sum uniform on {2,…,12}. ∎

(Remark: the same odd-degree argument rules out a uniform sum whenever the number of attainable sums is odd. The tempting wrong instinct — trying to solve the linear system in the ai,bj numerically — never terminates in a clean impossibility proof.)

Part 2: relabeling via cyclotomic factorization

For a fair die whose faces are positive integers, take counting generating functions: A(x)=∑ixfi over the six faces, so A has nonnegative integer coefficients, A(1)=6, and no constant term. Two such dice reproduce the standard sum distribution iff A(x)B(x)=(x+x2+x3+x4+x5+x6)2.

Factor the single standard die over ℚ into cyclotomic polynomials. Since 1+x+⋯+x5=x6−1x−1=Φ2Φ3Φ6 with Φ2=x+1, Φ3=x2+x+1, Φ6=x2−x+1, x+x2+⋯+x6=x(x+1)(x2+x+1)(x2−x+1). Hence A(x)B(x)=x2(x+1)2(x2+x+1)2(x2−x+1)2.

Because ℤ[x] is a UFD and these cyclotomic factors are irreducible, A and B are each products of a sub-multiset of the eight factors {x,x,(x+1),(x+1),(x2+x+1),(x2+x+1),(x2−x+1),(x2−x+1)}. Three constraints pin down the split:

Thus A(x)=x(x+1)(x2+x+1)(x2−x+1)β,B(x)=x(x+1)(x2+x+1)(x2−x+1)2−β.

Compute the nonstandard dice. With β=0: A(x)=x(x+1)(x2+x+1)=x4+2x3+2x2+x, so the faces are {1,2,2,3,3,4}. For the partner, expand B(x)=x(x+1)(x2+x+1)(x2−x+1)2. Since (x2−x+1)2=x4−2x3+3x2−2x+1 and (x+1)(x2+x+1)=x3+2x2+2x+1, their product is x7+x5+x4+x3+x2+1, and multiplying by x gives B(x)=x8+x6+x5+x4+x3+x, so the faces are {1,3,4,5,6,8}.

Conclusion. Up to swapping the two dice, exactly two pairs reproduce the standard two-dice sum distribution:

Pair Die A faces Die B faces
Standard 1,2,3,4,5,6 1,2,3,4,5,6
Sicherman 1,2,2,3,3,4 1,3,4,5,6,8

The unique nonstandard labeling is the Sicherman pair {1,2,2,3,3,4} and {1,3,4,5,6,8}. Both dice remain fair, each face equally likely, yet the sums 2,…,12 occur with the identical frequencies 1,2,3,4,5,6,5,4,3,2,1 out of 36.

(Note: the constraint A(1)=6 is what forces the (x+1) and (x2+x+1) factors to be shared symmetrically; only the self-reciprocal factor Φ6=x2−x+1 can migrate, which is exactly why there is one and only one alternative.)

Statistics in machine learning

Reading the Benjamini-Hochberg step-up rule off a sorted list

easy · Multiple testing, p-value pitfalls and false discovery rate

You have run m=10 independent hypothesis tests and obtained the following ten p-values, already sorted in increasing order p(1)≤…≤p(10):

0.001, 0.008, 0.012, 0.017, 0.023, 0.031, 0.034, 0.20, 0.30, 0.40.

The Benjamini-Hochberg (BH) procedure at level q finds

k⋆=max\{k:p(k)≤kmq\},

and rejects the hypotheses corresponding to p(1),…,p(k⋆) (rejecting nothing if no such k exists).

  1. Apply BH at q=0.05. Which hypotheses are rejected? Report k⋆ and the largest rejected p-value.
  2. A colleague scans the list from the top and stops the moment the inequality p(k)≤kmq first fails, rejecting everything above that point. On this data, does that shortcut give the same set of rejections? Explain in one sentence why the two rules can differ.
  3. Suppose that unknown to you, exactly m0=3 of the ten nulls are actually true. Under independence of the p-values, what is the guaranteed upper bound on the false discovery rate of the procedure in part 1?
Solution

Part 1: apply the rule

The BH cutoffs are kmq=k10(0.05)=0.005k. Tabulate p(k) against 0.005k:

k p(k) 0.005k p(k)≤0.005k?
1 0.001 0.005 yes
2 0.008 0.010 yes
3 0.012 0.015 yes
4 0.017 0.020 yes
5 0.023 0.025 yes
6 0.031 0.030 no
7 0.034 0.035 yes
8 0.20 0.040 no
9 0.30 0.045 no
10 0.40 0.050 no

The rule asks for the largest k satisfying the inequality, not the first failure. The inequality holds at k=7 (and fails at k=6), and fails for all k>7. Hence

k⋆=7.

BH rejects H(1),…,H(7): the seven hypotheses with p-values 0.001 through 0.034. The largest rejected p-value is 0.034.

Part 2: why the shortcut is wrong

The scan-from-top shortcut stops at k=6 (first failure) and would reject only the top five. It misses H(7).

BH is a step-up procedure: it starts from the largest index and steps down to the first success, so it takes the largest crossing point. The threshold 0.005k grows with k, so a p-value can sit above its own cutoff yet still be rejected because a later, larger cutoff is met — here p(6)=0.031>0.030, but because p(7)=0.034≤0.035, index 6 is rejected too. Stopping at the first failure is the classic mistake; it turns BH into an overly conservative rule.

Part 3: the FDR guarantee

The Benjamini-Hochberg theorem (1995) states that when the p-values are independent, the procedure at level q controls the false discovery rate at

𝔼[Vmax(R,1)]≤m0mq,

where m0 is the number of true nulls, V the number of false rejections, and R the total number of rejections. The factor m0/m appears because only true nulls can contribute false discoveries, and each true null's p-value is (sub-)uniform; the true alternatives cannot inflate the false-discovery count.

With m0=3, m=10, q=0.05:

FDR≤310(0.05)=0.015.

Closing note

Two tempting errors are worth flagging. First, confusing BH with a fixed threshold at q: rejecting every p≤0.05 would reject the eight smallest (through 0.034 — actually p(8)=0.20 is above, so seven here) with no FDR guarantee at all. Second, reading q itself as the achieved FDR bound; the actual guaranteed bound is m0mq, which is why BH is conservative when many alternatives are true. The guaranteed bound in part 3 is 0.015.


Two new problems every morning at 8am · every day so far