Generate random numbers following a normal distribution in C/C++
问题 How can I easily generate random numbers following a normal distribution in C or C++? I don\'t want any use of Boost. I know that Knuth talks about this at length but I don\'t have his books at hand right now. 回答1: There are many methods to generate Gaussian-distributed numbers from a regular RNG. The Box-Muller transform is commonly used. It correctly produces values with a normal distribution. The math is easy. You generate two (uniform) random numbers, and by applying an formula to them,