Académique Documents
Professionnel Documents
Culture Documents
Andrew DeMaio
March 3, 2019
Let’s call the number of packs that Arthur has to buy X (a random variable). This means
that his expected cost is $5·E[X]. To find E[X], break the problem down into a finer-detailed
random variable:
1
#!/usr/bin/python
def expected_purchases(n):
return n * sum(Fraction(1, i) for i in range(1, n+1))
This program outputs the answer of $3996.36, which feels excessive, Arthur.
P.S. Interestingly, the sum ni=1 1i is the Harmonic Series which, according to people smarter
P
than me, behaves an awful lot like the natural logarithm as n increases:
n
X 1
ln(n) < ≤ ln(n) + 1
i=1
i
Look at how E[X] compares to n ln(n) and n(ln(n) + 1) for the first 1000 n:
As an aside, the value n ln(n) recurs quite a bit in computer science, typically in the context
of sorting lists of numbers. In particular, the best algorithms for sorting a list with n elements
2
cost at least/at most cn ln(n) computations for some values of c > 0. Ultimately, this can
be understood in terms of Stirling’s approximation, which tells us that
n log22 (n)
+ cn log2 (n)
log2 (e)
bits of information, for some 0 < c ≤ 1; but Arthur could also have mixed n cards in a
random order. So you could imagine that Arthur found a way to mix up n cards with an
expected overhead of around log(n).