I’m tempted to run a full simulation that really picks those molecules randomly.
Comment on Soup of Theseus
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
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…
TranquilTurbulence@lemmy.zip 1 day ago
I thought of making a vector with a length of about 1.671398e+25, but then I remembered what one time when when I tried to make a linear model with hundreds of dimensions. So yeah… We have gigabytes of RAM, and it’s still not enough. Not really a problem, as long as you don’t try to do anything completely ridiculous.
Instead, I just made a variable that simply contains the number of soup molecules and another one for the number of water molecules. Far simpler that way.
Here’s where the magic happens:
The rbinom function is used to generate random numbers from a binomial distribution. It’s a discrete probability distribution that models the number of successes, i.e. scooping out a soup molecule. Rest of the codes is just basic infrastructure like variables, loops, etc.
BTW the variable names look ugly, because I couldn’t be bothered to tidy everything up. I really prefer camelCase, whereas Mistral seems to prefer underscores. That’s what you get for vibing.
Side note: If you do this kind of stuff for private purposes, you have to rely on your own hardware. If you plan to publish your discoveries, universities and publicly funded supercomputers might be an option. If there exists a Journal Of Recreational Mathematics And Useless Simulations (JORMAUS), I could totally publish this stuff and maybe even run my code on a supercomputer.
NeatNit@discuss.tchncs.de 23 hours ago
Interesting. 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.
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 1 day ago
If you want, I can increase the sample size. Just need to figure out how to add a timer to the code and set it to run for a few hours, maybe even overnight. A histogram with 10^6 bins should look pretty smooth.