QuoteOriginally posted by: outrunThis is a set of two C++11 compliant normal distributions named normal_distribution_inv and normal_distribution_inv_single. These C++ distribution sampler are used to generate normal distributed random numbers.C++11 has it's own std::normal_distribution<> in the <random> library to do this, and that version uses the Box Muller transform. It's the best plain vanilla method to generate normal distributed random numbers in C++11. This version is different because it uses *inversion* (the inverse of the cumulative normal distribution function) to convert uniform random numbers to normal distributed ones. It has different properties, and so can be useful for some special cases:* it might be a bit faster (I still need to benchmark it)* it's common to use inversion when using low discrepancy sequences. There is a worry that Box Muller breaks the low discrepancy structure because it consumes and mixes two random sample points/coordinated instead of one.I have two versions:sitmo::normal_distribution_inv<> which uses a full machine precision inversion functionsitmo::normal_distribution_inv_single<> which uses a faster 1.15E-9 precision inversion function.. I still need to do a lot of testing and I'll post updates if people find bugs or have suggestions for improvement. I might also add different distribution methods alter on, maybe Ziggurat?The code is based on the inversion function approximation by Peter John Acklamusage:sitmo::normal_distribution_inv<> N;double e = N(eng);(with eng some random engine...)Do you have a 101 main()? Can I use it for my online students? They use 1) Hull approx and 2) Boost implementation and others at the moment. BTW Using your prng for Box-Muller is good, although the Polar form seems to less accurate. Any ideas why?
Last edited by Cuchulainn
on December 27th, 2013, 11:00 pm, edited 1 time in total.