3 ms·
My personal anecdote: Math is not my strong side, to put it mildly, but I can write simulators just fine. When solving the first n Euler problems I got stuck on
by jacquesm 6y ago
My personal anecdote: Math is not my strong side, to put it mildly, but I can write simulators just fine. When solving the first n Euler problems I got stuck on the analytical solution of the chip defect problem. Simulating it was easy enough. But whoever put those Euler problems together was pretty clever: the simulated answer wasn't precise enough (8 digits instead of 10 if I recall), forcing you to find the analytical one, or to brute force the remaining two digits.
- dahart 6y agoThere are a couple of reasons that might happen. You’d have to use at least 64 bit doubles (or 64 bit ints if using fixed point), since a 32 bit float is ~7 digits of precision. Also if you’re plugging random numbers directly into the simulator like this article does, the convergence rate will be n^(1/2) which means that going from 8 digits of precision to 10 digits will take 10,000 times longer. In order to get a better convergence rate, you could use jittering/stratification or a low-discrepancy sequence instead of a bare random number generator. Even with a perfect QMC convergence rate of 1/n, getting 10 digits of precision reliably will take 100 times longer than 8 digits of precision. I don’t remember the chip defect problem, so I’m not sure whether I solved it. ;) But based on your description, and knowing that Euler problems are designed to be resistant to long computations, I might bet on the convergence rate being the issue. I saw your comment about using a better RNG, but if you used a 64-bit RNG, I doubt that is the problem, I think you’d get away with a low quality RNG if you waited long enough.