mirror of
https://github.com/ppy/osu
synced 2025-02-08 22:27:14 +00:00
Fix possible exception caused by log(0)
This commit is contained in:
parent
3356742ba2
commit
a912bcadf8
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user