Comment on Soup of Theseus
NeatNit@discuss.tchncs.de 2 days ago
Ok, let’s do the probability math properly. Others have mentioned how it’s a matter of probability how long until the last molecule of soup is taken out.
Suppositions:
There are N molecules in every ml of soup and every ml of water.
All soup molecules are the same.
Every spoonful takes out exactly 25N molecules out of the bowl selected at random, and they are immediately replaced by 25N molecules of water.
At the start, there are 500N molecules of soup in the bowl.
The question is:
How many spoonfuls is it expected to take until all soup molecules are removed?
For every spoonful, each molecule of soup in the bowl has a 25/500 chance of being removed from the bowl.
For ease of calculation, I will assume that each molecule being removed is independent of all others. This is technically wrong, because this implies that there is a very very tiny chance that all soup molecules are replaced in the very first spoonful. However, for the large number of molecules we are going to be working with, this shouldn’t affect the final result in any meaningful way.
Number all soup molecules in the bowl: 1, 2, …, 500N.
Define X_i to be the number of iterations it took until molecule i was removed. All X_i are I.I.D.:
P(X_i = 1) = 25/500 P(X_i = 2) = (475/500) * 25/500 P(X_i = 3) = (475/500)² * 25/500 … P(X_i = n) = (475/500)^(n-1) * 25/500
This is a geometric distribution with p = 25/500.
Now what we’re interested in if the maximum value between all X_i
That is: max_i { X_i }
Specifically we want the “Expected Value” (basically the average) of it: E[ max_i { X_i } ]
This is exactly the question asked here: math.stackexchange.com/q/26167
According to the answer there, there is no closed-form exact answer but a very good approximation for the solution is:
1/2 + (1/λ) H_N
Where λ = -log(1-p) and H_n is the nth harmonic number.
Now it’s just a matter of plugging in the numbers.
According to Wolfram Alpha, there are N = 3.333*10^22 molecules in 1mL of water.
Again using Wolfram Alpha, the Nth harmonic number is H_N = 52.438
With the formula given we get λ = -log(475/500) = 0.051293
Plugging it all in we get the expected number of spoonfuls:
1022.8
TranquilTurbulence@lemmy.zip 2 days ago
Wow, someone actually bothered to do it properly! I just wrote some horrible R code and ended up with 1146 spoons to get to 50% probability of having either 1 or 0 soup molecules. So good to see that the answers were so close.
NeatNit@discuss.tchncs.de 2 days ago
:)
What I would like to do is give a margin of error, e.g. “there is a 95% change that it will be between spoonful 1000 and spoonful 1300” or something like that. But I don’t have the time to figure that out now, sounds like it would be harder to figure out than the expected value.
TranquilTurbulence@lemmy.zip 1 day ago
Ok, I couldn’t resist. Here are the results of running that simulation 6000 times.
histogram
This means that about half the time it’s somewhere between 1126 and 1157 spoons.
FYI: /u/protist@mander.xyz, /u/Sabin10@lemmy.world, /u/neo2478@sh.itjust.works
NeatNit@discuss.tchncs.de 1 day ago
By the way, how did you actually stimulate it? Surely you didn’t keep 10^25 variables in memory…
NeatNit@discuss.tchncs.de 1 day ago
You rock! Thank you :)
If I find myself in the right mood I might try to work out the actual distribution. If I do, your simulation will be a very handy sanity check!
TranquilTurbulence@lemmy.zip 2 days ago
I’m tempted to run a full simulation that really picks those molecules randomly.