Comment on Soup of Theseus
NeatNit@discuss.tchncs.de 1 day agoInteresting. I don’t know why I didn’t think of just keeping a count of soup molecules. Must have been late!
Another interesting point, your simulation is subtly wrong in a different way from my calculation. When there is only one soup molecule left, there is a chance (however tiny) that rbinom
will return 2 or more, taking out more soup molecules than there really are.
If you run it enough times with a bowl of 3 molecules and a spoon of 2 molecules, I’m sure you’ll hit -1 soup molecules some of the time.
For a simulation I think we can do better. There must be a random function that does it properly. The function we want is like pulling balls of 2 colors out of a sack without replacement. Pretty common combinatorics question, I would expect a random function to match.
TranquilTurbulence@lemmy.zip 1 day ago
You’re right. I just ran rbinom 1E7 times and found that the probability of over drawing soup molecules is a bit too high for my taste.
When there’s only 1 left, you usually end up drawing 0 or 1 molecule. However, in rare cases, it can be higher, such as 2, 3, 4… molecules.
About 92% was 0, and 7.7% was 1, but the others were not negligible! There’s about 0.3% probability of over drawing, which is way too high for a simulation as serious as this one. In this quick test, there were 20 incidents where rbinom wanted to pull out 4 soup molecules when only 1 was available. We can’t have that, now can we!
NeatNit@discuss.tchncs.de 1 day ago
In python the closest I could find was (untested): sum(random.sample([1, 0], spoon_size, counts=[soup_count, water_count]))
But this would create an intermediate list of length spoon_size which is not a good idea.
NeatNit@discuss.tchncs.de 1 day ago
/u/TranquilTurbulence@lemmy.zip fairly sure the distribution you should use is hypergeometric distribution, found via urn problem.
TranquilTurbulence@lemmy.zip 22 hours ago
Hmmm… The description certainly fits. Just by eye-balling the graphs, they look very different from what I got, but I guess that’s just the expected result of running rbinom about a 6 million times. With a smaller simulation, it might not have been so apparent. Also, that’s what you get for skipping the maths and vibing the code without thinking too much about the details. Well, at least i got this far with absolutely minimal effort. :D
It appears that I need to switch to a better distribution. Thanks for looking into this mystery!