I often write small Monte Carlo simulations to solve difficult probability problems.
What’s the best (fastest, most accurate) RNG for this type of use?
I often write small Monte Carlo simulations to solve difficult probability problems.
What’s the best (fastest, most accurate) RNG for this type of use?
The best sampling of the input distributions is likely not from any random-number generator, instead, you may want to look into “low-discrepancy sequences” which result in lower variance than random sampling.
Thanks for your reply. That is very interesting. I’ve been wondering about something very similar to that, but did not realize it had already been substantially studied.
Is there a package in Julia that generates quasi-random numbers?
Many of the problems I want to simulate involve randomly drawing a car from a standard deck, one at a time, without replacement, until a certain condition is met, and then stopping; and then repeating that experiment many times to compute the expected value of draws.
Would quasi-random numbers be suitable for simulation like that?
I typically run a billion or more trials when I’m using rand() and get surprisingly accurate results. Would quasi-random numbers run faster and produce more accurate results?
We have Sobol.jl for generating quasi monte carlo experiments but the repository seems a little bit outdated.
Sobol.jl is great and continues to work without errors on newer versions of Julia.
Can/should these quasirandom sequences be used as the default go-to choice for all Monte-Carlo simulations, instead of regular PRNGs?
Like, if I calculate probabilities mean(_ -> f(rng) > x, 1:10^4)
for a black-box f(rng)
, should I just replace rng
with a Sobol sequence generator? Should it improve sampling efficiency in general?
I think the general idea is that Quasi-Monte Carlo would be a better choice for that, yea. I have also seen mixing, where you do both QMC and regular MC together.
Does it depend on what f
actually does with rng
, or how many numbers does it draw from it?
If QMC is generally better for this kind of problems, then should it just be used “everywhere” except security and similar stuff?
I haven’t heard much about QMC before, so maybe these questions seem obvious (:
Though I’d also say it still needs quite some work, the basics are all there.
I think it probably does depend what you are doing with it. Also note that you can’t quite “just swap” it out. The Sobol sequences are on the unit cube, so if you may need to transform the draws to fit your randomness (eg invert using the CDF).
Also that SciML package looks great.
Regular random generators are also on the “unit cube” originally – they generate numbers from 0…1 or integers, that are transformed to whatever is needed. Seems like it’s possible to implement the same Julia RNG interface that’s backed by Sobol sequences, and simply swap RNG with Q-RNG.
Yes I just wanted to be explicit so that we (and all others) were on the same page. If you were drawing random numbers using randn
, you cannot just directly swap out for the Sobol sequence!
It still works and is maintained as needed.
For small packages that do one well-defined task, “updated frequently” is not such a reliable heuristic. For such packages, my goal is generally to get it featured-complete and then never have to touch it except to fix bugs or version-compatibility issues.