Table of Contents

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)

Returns a random bool value. true and false are equally probable.

public static bool NextBoolean(this Random random)

Parameters

random Random

The random number generator.

Returns

bool

A random bool value.

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

random Random

The random number generator.

min double

The inclusive lower bound of the interval.

max double

The 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

random Random

The 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

random Random

The random number generator.

mu double

The mean of the distribution.

sigma double

The 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.