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
1 changed files with 2 additions and 2 deletions

View File

@ -212,8 +212,8 @@ public static bool IsHitObjectOnBeat(OsuBeatmap beatmap, OsuHitObject hitObject,
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;
}