Fix possible exception caused by log(0)

This commit is contained in:
Pasi4K5 2022-06-20 00:19:29 +02:00
parent 3356742ba2
commit a912bcadf8

View File

@ -212,8 +212,8 @@ namespace osu.Game.Rulesets.Osu.Utils
public static float RandomGaussian(Random rng, float mean = 0, float stdDev = 1)
{
double x1 = rng.NextDouble();
double x2 = rng.NextDouble();
double x1 = 1 - rng.NextDouble();
double x2 = 1 - rng.NextDouble();
double stdNormal = Math.Sqrt(-2 * Math.Log(x1)) * Math.Sin(2 * Math.PI * x2);
return mean + stdDev * (float)stdNormal;
}