Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

A computation from a talk given on 4/2/16 at the Allegheny Mountain Section of the MAA annual meeting.

Views: 42

If at each stage, one candy is removed from a bowl with rr red candies out of NN total candies, and a replacement candy is generated based on the resulting distribution in the bowl, the expected number of steps before we reach either 00 or NN red candies can be computed as [ (N-1) \left( (N-r) \sum_{j = 1}^r \frac{1}{N-j} +r \sum_{j = r+1}^{n-1} \frac{1}{j} \right) ] The function dirComp(N, r) below will compute this for a bowl with NN candies, starting with rr red:

def dirComp(N, r): return (N-1)*((N-r)*(sum([1/(N-j) for j in range(1, r+1)])) + r*sum([1/j for j in range(r+1, N)]))

Example: Here is a table of results for N=10N = 10:

table([ (i, dirComp(10, i), n(dirComp(10, i))) for i in range(1, 10)], header_row=("r", "Expected", "(Approximate)"))
r Expected (Approximate) +---+----------+------------------+ 1 7129/280 25.4607142857143 2 5729/140 40.9214285714286 3 3553/70 50.7571428571429 4 7883/140 56.3071428571429 5 1627/28 58.1071428571429 6 7883/140 56.3071428571429 7 3553/70 50.7571428571429 8 5729/140 40.9214285714286 9 7129/280 25.4607142857143

Here's a partial table with N=100N = 100 (leaving out the exact values, which are ugly fractions here):

table([ (i, n(dirComp(100, i))) for i in range(1, 20)], header_row=("r", "(Approximate)"))
r (Approximate) +----+------------------+ 1 512.560374246322 2 925.120748492645 3 1287.17091865733 4 1615.20047026532 5 1917.44877187331 6 2198.85496821814 7 2462.70797307361 8 2711.35360465719 9 2946.54814928425 10 3169.65478182340 11 3381.76141436254 12 3583.75568735113 13 3776.37496033971 14 3960.24091767843 15 4135.88428365502 16 4303.76294374925 17 4464.27553241492 18 4617.77182058448 19 4764.56079168088