Joe has two bottles of seasick pills, each stocked with 40 pills, which he takes with him on his ocean voyage.
During the trip, each time he takes a pill he chooses one of the two bottles at random with equal probability. Eventually one will run out and he's left with the other. When whichever is the first to run out does so, what's the expected value of the number of pills left in the other bottle?
(In reply to
Solution Google Sheets by Jer)
Well, Jer found the definitive solution of 7.114230302 posted at: http://perplexus.info/show.php?pid=12108&cid=62406
I ran a confirmatory simulation which flipped 10^7 coins and came up with 7.1164127 which is pretty close.
----- code -----
import random
remaining = []
exponent = 7
for i in range(10**exponent):
a = 40
b = 40
while min(a,b) > 0:
r = random.randint(0, 1)
if r == 0:
a -= 1
elif r == 1:
b -= 1
remaining.append(max(a,b))
print(sum(remaining)/len(remaining))
Edited on March 1, 2021, 7:31 pm
|
Posted by Larry
on 2021-03-01 19:30:18 |