C# 클래스 PeterO.RandomGenerator

A class that adapts a random byte generator to generate random numbers in a variety of statistical distributions.

The method descriptions in this class assume the underlying random byte generator generates uniformly distributed numbers that are independent of each other.

Thread safety: The methods in this class are safe for concurrent use by multiple threads, as long as the underlying random byte generator is as well.

파일 보기 프로젝트 열기: peteroupc/CBOR 1 사용 예제들

공개 메소드들

메소드 설명
Bernoulli ( ) : bool

Returns either true or false at a 50% chance each.

Bernoulli ( double p ) : bool

Returns either true or false, depending on the given probability.

Binomial ( int trials ) : int

Conceptually, generates either 1 or 0 the given number of times, where either number is equally likely, and counts the number of 1's generated.

Binomial ( int trials, double p ) : int

Conceptually, generates either 1 or 0 the given number of times, where a 1 is generated at the given probability, and counts the number of 1's generated.

ChiSquared ( int df ) : double

Generates a random number that is the sum of the squares of "df" normally-distributed random numbers with a mean of 0 and a standard deviation of 1.

Exponential ( ) : double

Not documented yet.

Gamma ( double a ) : double

Not documented yet.

Gamma ( double a, double b ) : double

Not documented yet.

Geometric ( ) : int

Conceptually, generates either 1 or 0 until a 1 is generated, and counts the number of 0's generated. Either number has an equal probability of being generated.

Geometric ( double p ) : int

Conceptually, generates either 1 or 0 until a 1 is generated, and counts the number of 0's generated. A 1 is generated at the given probability.

Hypergeometric ( int trials, int ones, int count ) : int

Conceptually, given a set of tokens, some of which are labeled 1 and the others labeled 0, draws "trials" tokens at random without replacement and then counts the number of 1's drawn.

LogNormal ( double mean, double sd ) : double

Generates a logarithmic normally-distributed number with the given mean and standard deviation.

NegativeBinomial ( int trials ) : int

Conceptually, generates either 1 or 0 the given number of times until the given number of 1's are generated, and counts the number of 0's generated. Either number has an equal probability of being generated.

NegativeBinomial ( int trials, double p ) : int

Conceptually, generates either 1 or 0 until the given number of 1's are generated, and counts the number of 0's generated. A 1 is generated at the given probability.

Normal ( ) : double

Generates a normally-distributed number with mean 0 and standard deviation 1.

Normal ( double mean, double sd ) : double

Generates a normally-distributed number with the given mean and standard deviation.

Poisson ( double mean ) : int

Generates a random integer such that the average of random numbers approaches the given mean number when this method is called repeatedly with the same mean.

RandomGenerator ( ) : System

Initializes a new instance of the RandomGenerator class.

RandomGenerator ( IRandomGen valueIrg ) : System

Initializes a new instance of the RandomGenerator class.

Uniform ( ) : double

Returns a uniformly-distributed 64-bit floating-point number from 0 and up, but less than 1.

Uniform ( double max ) : double

Returns a uniformly-distributed 64-bit floating-point number from 0 and up, but less than the given number.

Uniform ( double min, double max ) : double

Not documented yet.

UniformInt ( int maxExclusive ) : int

Generates a random 32-bit signed integer 0 or greater and less than the given number.

UniformInt ( int minInclusive, int maxExclusive ) : int

Generates a random 32-bit signed integer within a given range.

UniformLong ( long maxExclusive ) : long

Generates a random 32-bit signed integer 0 or greater and less than the given number.

UniformLong ( long minInclusive, long maxExclusive ) : long

Generates a random 64-bit signed integer within a given range.

UniformSingle ( ) : double

Returns a uniformly-distributed 32-bit floating-point number from 0 and up, but less than 1.

비공개 메소드들

메소드 설명
NonZeroUniform ( ) : double

메소드 상세

Bernoulli() 공개 메소드

Returns either true or false at a 50% chance each.
public Bernoulli ( ) : bool
리턴 bool

Bernoulli() 공개 메소드

Returns either true or false, depending on the given probability.
public Bernoulli ( double p ) : bool
p double A probability from 0 through 1. 0 means always /// false, and 1 means always true.
리턴 bool

Binomial() 공개 메소드

Conceptually, generates either 1 or 0 the given number of times, where either number is equally likely, and counts the number of 1's generated.
public Binomial ( int trials ) : int
trials int The number of times to generate a random /// number, conceptually.
리턴 int

Binomial() 공개 메소드

Conceptually, generates either 1 or 0 the given number of times, where a 1 is generated at the given probability, and counts the number of 1's generated.
public Binomial ( int trials, double p ) : int
trials int The number of times to generate a random /// number, conceptually.
p double The probability for each trial to succeed, from 0 /// (never) to 1 (always).
리턴 int

ChiSquared() 공개 메소드

Generates a random number that is the sum of the squares of "df" normally-distributed random numbers with a mean of 0 and a standard deviation of 1.
public ChiSquared ( int df ) : double
df int Degrees of freedom (the number of independently /// chosen normally-distributed numbers).
리턴 double

Exponential() 공개 메소드

Not documented yet.
public Exponential ( ) : double
리턴 double

Gamma() 공개 메소드

Not documented yet.
public Gamma ( double a ) : double
a double Another 64-bit floating-point number.
리턴 double

Gamma() 공개 메소드

Not documented yet.
public Gamma ( double a, double b ) : double
a double Another 64-bit floating-point number.
b double A 64-bit floating-point number. (3).
리턴 double

Geometric() 공개 메소드

Conceptually, generates either 1 or 0 until a 1 is generated, and counts the number of 0's generated. Either number has an equal probability of being generated.
public Geometric ( ) : int
리턴 int

Geometric() 공개 메소드

Conceptually, generates either 1 or 0 until a 1 is generated, and counts the number of 0's generated. A 1 is generated at the given probability.
public Geometric ( double p ) : int
p double A 64-bit floating-point number.
리턴 int

Hypergeometric() 공개 메소드

Conceptually, given a set of tokens, some of which are labeled 1 and the others labeled 0, draws "trials" tokens at random without replacement and then counts the number of 1's drawn.
public Hypergeometric ( int trials, int ones, int count ) : int
trials int The number of tokens drawn at random without /// replacement.
ones int The number of tokens labeled 1.
count int The number of tokens labeled 1 or 0.
리턴 int

LogNormal() 공개 메소드

Generates a logarithmic normally-distributed number with the given mean and standard deviation.
public LogNormal ( double mean, double sd ) : double
mean double The desired mean.
sd double Standard deviation.
리턴 double

NegativeBinomial() 공개 메소드

Conceptually, generates either 1 or 0 the given number of times until the given number of 1's are generated, and counts the number of 0's generated. Either number has an equal probability of being generated.
public NegativeBinomial ( int trials ) : int
trials int The number of 1's to generate before the /// process stops.
리턴 int

NegativeBinomial() 공개 메소드

Conceptually, generates either 1 or 0 until the given number of 1's are generated, and counts the number of 0's generated. A 1 is generated at the given probability.
public NegativeBinomial ( int trials, double p ) : int
trials int The number of 1's to generate before the /// process stops.
p double The probability for each trial to succeed, from 0 /// (never) to 1 (always).
리턴 int

Normal() 공개 메소드

Generates a normally-distributed number with mean 0 and standard deviation 1.
public Normal ( ) : double
리턴 double

Normal() 공개 메소드

Generates a normally-distributed number with the given mean and standard deviation.
public Normal ( double mean, double sd ) : double
mean double The desired mean.
sd double Standard deviation.
리턴 double

Poisson() 공개 메소드

Generates a random integer such that the average of random numbers approaches the given mean number when this method is called repeatedly with the same mean.
public Poisson ( double mean ) : int
mean double The expected mean of the random numbers.
리턴 int

RandomGenerator() 공개 메소드

Initializes a new instance of the RandomGenerator class.
public RandomGenerator ( ) : System
리턴 System

RandomGenerator() 공개 메소드

Initializes a new instance of the RandomGenerator class.
public RandomGenerator ( IRandomGen valueIrg ) : System
valueIrg IRandomGen An IRandomGen object.
리턴 System

Uniform() 공개 메소드

Returns a uniformly-distributed 64-bit floating-point number from 0 and up, but less than 1.
public Uniform ( ) : double
리턴 double

Uniform() 공개 메소드

Returns a uniformly-distributed 64-bit floating-point number from 0 and up, but less than the given number.
public Uniform ( double max ) : double
max double Number that the randomly-generated number will be /// less than.
리턴 double

Uniform() 공개 메소드

Not documented yet.
public Uniform ( double min, double max ) : double
min double Smallest possible number that will be /// generated.
max double Number that the randomly-generated number will be /// less than.
리턴 double

UniformInt() 공개 메소드

Generates a random 32-bit signed integer 0 or greater and less than the given number.
public UniformInt ( int maxExclusive ) : int
maxExclusive int One plus the largest possible value of /// the random number.
리턴 int

UniformInt() 공개 메소드

Generates a random 32-bit signed integer within a given range.
public UniformInt ( int minInclusive, int maxExclusive ) : int
minInclusive int Smallest possible value of the random /// number.
maxExclusive int One plus the largest possible value of /// the random number.
리턴 int

UniformLong() 공개 메소드

Generates a random 32-bit signed integer 0 or greater and less than the given number.
public UniformLong ( long maxExclusive ) : long
maxExclusive long One plus the largest possible value of /// the random number.
리턴 long

UniformLong() 공개 메소드

Generates a random 64-bit signed integer within a given range.
public UniformLong ( long minInclusive, long maxExclusive ) : long
minInclusive long Smallest possible value of the random /// number.
maxExclusive long One plus the largest possible value of /// the random number.
리턴 long

UniformSingle() 공개 메소드

Returns a uniformly-distributed 32-bit floating-point number from 0 and up, but less than 1.
public UniformSingle ( ) : double
리턴 double