1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Add comments and XML doc

This commit is contained in:
Pasi4K5 2022-06-22 16:49:07 +02:00
parent a912bcadf8
commit 2f1186d328

View File

@ -210,10 +210,16 @@ namespace osu.Game.Rulesets.Osu.Utils
return (timeSinceTimingPoint + 1) % length < 2;
}
/// <summary>
/// Generates a random number from a normal distribution using the Box-Muller transform.
/// </summary>
public static float RandomGaussian(Random rng, float mean = 0, float stdDev = 1)
{
// Generate 2 random numbers in the interval (0,1].
// x1 must not be 0 since log(0) = undefined.
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;
}