C# Class numl.Math.Probability.Sampling

SimpleRNG is a simple random number generator based on George Marsaglia's MWC (multiply with carry) generator. Although it is very simple, it passes Marsaglia's DIEHARD series of random number generator tests. Written by John D. Cook http://www.johndcook.com.
显示文件 Open project: sethjuarez/numl Class Usage Examples

Public Methods

Method Description
GetBeta ( double a, double b ) : double

Gets a beta.

GetCauchy ( double median, double scale ) : double

Gets a cauchy.

GetChiSquare ( double degreesOfFreedom ) : double

Gets chi square.

GetExponential ( ) : double

Exponential random sample with mean 1.

GetExponential ( double mean ) : double

Exponential random sample with specified mean.

GetGamma ( double shape, double scale ) : double

Gets a gamma.

GetInverseGamma ( double shape, double scale ) : double

Gets inverse gamma.

GetLaplace ( double mean, double scale ) : double

The Laplace distribution is also known as the double exponential distribution.

GetLogNormal ( double mu, double sigma ) : double

Gets log normal.

GetNormal ( ) : double

Normal (Gaussian) random sample with mean 0 and standard deviation 1.

GetNormal ( double mean, double standardDeviation ) : double

Normal (Gaussian) random sample with specified mean and standard deviation.

GetPower ( double a, double min = 1 ) : double

Gets a power.

GetStudentT ( double degreesOfFreedom ) : double

Gets student.

GetUniform ( ) : double

Produce a uniform random sample from the open interval (0, 1). The method will not return either end point.

GetUniform ( double min = 0d, double max = 1.0d ) : double

Produce a uniform random sample from the open interval (min, max inclusive). The method can return either end point

GetUniform ( int max ) : int

Produce a uniform random sample from the open interval (0, max). The method will not return either end point.

GetUniform ( int min, int max ) : int

Produce a uniform random sample from the open interval (min, max). The method can return either end point.

GetWeibull ( double shape, double scale ) : double

Gets a weibull.

SetSeedFromSystemTime ( ) : void

Creates random number generator seed.

SetSeedFromTime ( System.DateTime dt ) : void

Set random seed from a specified time

Private Methods

Method Description
GetUint ( ) : uint

This is the heart of the generator. It uses George Marsaglia's MWC algorithm to produce an unsigned integer. See http://www.bobwheeler.com/statistics/Password/MarsagliaPost.txt.

Sampling ( ) : System

Static constructor.

SetSeed ( uint u ) : void

Sets a seed.

SetSeed ( uint u, uint v ) : void

The random generator seed can be set three ways: 1) specifying two non-zero unsigned integers 2) specifying one non-zero unsigned integer and taking a default value for the second 3) setting the seed from the system time.

Method Details

GetBeta() public static method

Gets a beta.
Thrown when one or more arguments are outside the /// required range.
public static GetBeta ( double a, double b ) : double
a double The double to process.
b double The double to process.
return double

GetCauchy() public static method

Gets a cauchy.
Thrown when one or more arguments have unsupported or /// illegal values.
public static GetCauchy ( double median, double scale ) : double
median double The median.
scale double The scale.
return double

GetChiSquare() public static method

Gets chi square.
public static GetChiSquare ( double degreesOfFreedom ) : double
degreesOfFreedom double The degrees of freedom.
return double

GetExponential() public static method

Exponential random sample with mean 1.
public static GetExponential ( ) : double
return double

GetExponential() public static method

Exponential random sample with specified mean.
Thrown when one or more arguments are outside the /// required range.
public static GetExponential ( double mean ) : double
mean double mean parameter.
return double

GetGamma() public static method

Gets a gamma.
Thrown when one or more arguments are outside the /// required range.
public static GetGamma ( double shape, double scale ) : double
shape double The shape.
scale double The scale.
return double

GetInverseGamma() public static method

Gets inverse gamma.
public static GetInverseGamma ( double shape, double scale ) : double
shape double The shape.
scale double The scale.
return double

GetLaplace() public static method

The Laplace distribution is also known as the double exponential distribution.
public static GetLaplace ( double mean, double scale ) : double
mean double Mean.
scale double The scale.
return double

GetLogNormal() public static method

Gets log normal.
public static GetLogNormal ( double mu, double sigma ) : double
mu double The mu.
sigma double The sigma.
return double

GetNormal() public static method

Normal (Gaussian) random sample with mean 0 and standard deviation 1.
public static GetNormal ( ) : double
return double

GetNormal() public static method

Normal (Gaussian) random sample with specified mean and standard deviation.
Thrown when one or more arguments are outside the /// required range.
public static GetNormal ( double mean, double standardDeviation ) : double
mean double Mean.
standardDeviation double Standard deviation.
return double

GetPower() public static method

Gets a power.
public static GetPower ( double a, double min = 1 ) : double
a double The double to process.
min double (Optional) Min (exclusive)
return double

GetStudentT() public static method

Gets student.
Thrown when one or more arguments have unsupported or /// illegal values.
public static GetStudentT ( double degreesOfFreedom ) : double
degreesOfFreedom double The degrees of freedom.
return double

GetUniform() public static method

Produce a uniform random sample from the open interval (0, 1). The method will not return either end point.
public static GetUniform ( ) : double
return double

GetUniform() public static method

Produce a uniform random sample from the open interval (min, max inclusive). The method can return either end point
public static GetUniform ( double min = 0d, double max = 1.0d ) : double
min double
max double
return double

GetUniform() public static method

Produce a uniform random sample from the open interval (0, max). The method will not return either end point.
public static GetUniform ( int max ) : int
max int Max (Exclusive)
return int

GetUniform() public static method

Produce a uniform random sample from the open interval (min, max). The method can return either end point.
public static GetUniform ( int min, int max ) : int
min int Min (exclusive)
max int Max (exclusive)
return int

GetWeibull() public static method

Gets a weibull.
Thrown when one or more arguments are outside the /// required range.
public static GetWeibull ( double shape, double scale ) : double
shape double The shape.
scale double The scale.
return double

SetSeedFromSystemTime() public static method

Creates random number generator seed.
public static SetSeedFromSystemTime ( ) : void
return void

SetSeedFromTime() public static method

Set random seed from a specified time
public static SetSeedFromTime ( System.DateTime dt ) : void
dt System.DateTime date time
return void