我想在 C# 中编写一个方法来生成一个随机数,其中高斯分布在范围内[0:1]
(并且提前在 [0-x] 中)。我找到了这段代码但不能正常工作
Random rand = new Random(); //reuse this if you are generating many
double u1 = rand.NextDouble(); //these are uniform(0,1) random doubles
double u2 = rand.NextDouble();
double randStdNormal = Math.Abs( Math.Sqrt(-2.0 * Math.Log(u1)) *
Math.Sin(2.0 * Math.PI * u2));