Class RandomExtensions
- Namespace
- Evolutionary
- Assembly
- Evolutionary.dll
Provides extension methods for the Random class, that are missing in the .NET Base Class Library.
public static class RandomExtensions
- Inheritance
-
RandomExtensions
- Inherited Members
Methods
NextBoolean(Random)
public static bool NextBoolean(this Random random)
Parameters
randomRandomThe random number generator.
Returns
NextDouble(Random, double, double)
Returns a uniformly distributed random number within the interval
[min, max). The value
max itself is excluded from the interval.
public static double NextDouble(this Random random, double min, double max)
Parameters
randomRandomThe random number generator.
mindoubleThe inclusive lower bound of the interval.
maxdoubleThe exclusive upper bound of the interval.
Returns
- double
A uniformly distributed random number within the given interval.
NextNormal(Random)
Returns a standard normally distributed random number, that is a random number with a mean of 0 and a standard deviation of 1.
public static double NextNormal(this Random random)
Parameters
randomRandomThe random number generator.
Returns
- double
A standard normally distributed random number.
NextNormal(Random, double, double)
Returns a normally distributed random number with the given mean
value mu and the standard deviation
sigma.
public static double NextNormal(this Random random, double mu, double sigma)
Parameters
randomRandomThe random number generator.
mudoubleThe mean of the distribution.
sigmadoubleThe standard deviation of the distribution.
Returns
- double
A normally distributed random number.
Remarks
The method uses the Box-Muller transform to convert two uniformly distributed random values into one normally distributed random value.