Class 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.
Inheritance
Inherited Members
Namespace:numl.Math.Probability
Assembly:numl.dll
Syntax
public class Sampling
Methods
View SourceGetBeta(Double, Double)
Gets a beta.
Declaration
public static double GetBeta(double a, double b)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | The double to process. |
System.Double | b | The double to process. |
Returns
Type | Description |
---|---|
System.Double | The beta. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when one or more arguments are outside the required range. |
GetCauchy(Double, Double)
Gets a cauchy.
Declaration
public static double GetCauchy(double median, double scale)
Parameters
Type | Name | Description |
---|---|---|
System.Double | median | The median. |
System.Double | scale | The scale. |
Returns
Type | Description |
---|---|
System.Double | The cauchy. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when one or more arguments have unsupported or illegal values. |
GetChiSquare(Double)
Gets chi square.
Declaration
public static double GetChiSquare(double degreesOfFreedom)
Parameters
Type | Name | Description |
---|---|---|
System.Double | degreesOfFreedom | The degrees of freedom. |
Returns
Type | Description |
---|---|
System.Double | The chi square. |
GetExponential()
Exponential random sample with mean 1.
Declaration
public static double GetExponential()
Returns
Type | Description |
---|---|
System.Double | Random Sample. |
GetExponential(Double)
Exponential random sample with specified mean.
Declaration
public static double GetExponential(double mean)
Parameters
Type | Name | Description |
---|---|---|
System.Double | mean | mean parameter. |
Returns
Type | Description |
---|---|
System.Double | Random Sample. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when one or more arguments are outside the required range. |
GetGamma(Double, Double)
Gets a gamma.
Declaration
public static double GetGamma(double shape, double scale)
Parameters
Type | Name | Description |
---|---|---|
System.Double | shape | The shape. |
System.Double | scale | The scale. |
Returns
Type | Description |
---|---|
System.Double | The gamma. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when one or more arguments are outside the required range. |
GetInverseGamma(Double, Double)
Gets inverse gamma.
Declaration
public static double GetInverseGamma(double shape, double scale)
Parameters
Type | Name | Description |
---|---|---|
System.Double | shape | The shape. |
System.Double | scale | The scale. |
Returns
Type | Description |
---|---|
System.Double | The inverse gamma. |
GetLaplace(Double, Double)
The Laplace distribution is also known as the double exponential distribution.
Declaration
public static double GetLaplace(double mean, double scale)
Parameters
Type | Name | Description |
---|---|---|
System.Double | mean | Mean. |
System.Double | scale | The scale. |
Returns
Type | Description |
---|---|
System.Double | The laplace. |
GetLogNormal(Double, Double)
Gets log normal.
Declaration
public static double GetLogNormal(double mu, double sigma)
Parameters
Type | Name | Description |
---|---|---|
System.Double | mu | The mu. |
System.Double | sigma | The sigma. |
Returns
Type | Description |
---|---|
System.Double | The log normal. |
GetNormal()
Normal (Gaussian) random sample with mean 0 and standard deviation 1.
Declaration
public static double GetNormal()
Returns
Type | Description |
---|---|
System.Double | Random Sample. |
GetNormal(Double, Double)
Normal (Gaussian) random sample with specified mean and standard deviation.
Declaration
public static double GetNormal(double mean, double standardDeviation)
Parameters
Type | Name | Description |
---|---|---|
System.Double | mean | Mean. |
System.Double | standardDeviation | Standard deviation. |
Returns
Type | Description |
---|---|
System.Double | Random Sample. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when one or more arguments are outside the required range. |
GetPower(Double, Double)
Gets a power.
Declaration
public static double GetPower(double a, double min = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Double | a | The double to process. |
System.Double | min | (Optional) Min (exclusive) |
Returns
Type | Description |
---|---|
System.Double | The power. |
GetStudentT(Double)
Gets student.
Declaration
public static double GetStudentT(double degreesOfFreedom)
Parameters
Type | Name | Description |
---|---|---|
System.Double | degreesOfFreedom | The degrees of freedom. |
Returns
Type | Description |
---|---|
System.Double | The student. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown when one or more arguments have unsupported or illegal values. |
GetUniform()
Produce a uniform random sample from the open interval (0, 1). The method will not return either end point.
Declaration
public static double GetUniform()
Returns
Type | Description |
---|---|
System.Double | Random Sample. |
GetUniform(Double, Double)
Produce a uniform random sample from the open interval (min, max inclusive). The method can return either end point
Declaration
public static double GetUniform(double min = 0, double max = 1)
Parameters
Type | Name | Description |
---|---|---|
System.Double | min | |
System.Double | max |
Returns
Type | Description |
---|---|
System.Double |
GetUniform(Int32)
Produce a uniform random sample from the open interval (0, max). The method will not return either end point.
Declaration
public static int GetUniform(int max)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | max | Max (Exclusive) |
Returns
Type | Description |
---|---|
System.Int32 | Random Sample. |
GetUniform(Int32, Int32)
Produce a uniform random sample from the open interval (min, max). The method can return either end point.
Declaration
public static int GetUniform(int min, int max)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | min | Min (exclusive) |
System.Int32 | max | Max (exclusive) |
Returns
Type | Description |
---|---|
System.Int32 | Random Sample. |
GetWeibull(Double, Double)
Gets a weibull.
Declaration
public static double GetWeibull(double shape, double scale)
Parameters
Type | Name | Description |
---|---|---|
System.Double | shape | The shape. |
System.Double | scale | The scale. |
Returns
Type | Description |
---|---|
System.Double | The weibull. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when one or more arguments are outside the required range. |
SetSeedFromSystemTime()
Creates random number generator seed.
Declaration
public static void SetSeedFromSystemTime()
SetSeedFromTime(DateTime)
Set random seed from a specified time
Declaration
public static void SetSeedFromTime(DateTime dt)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dt | date time |