MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffe.basecode.CryptoRandom Class Reference

The CryptoRandom is a random number generator that can use either the standard .Net Random objec or the more precise RandomNumberGenerator defined within the System.Security.Cryptograph. More...

Inheritance diagram for MyCaffe.basecode.CryptoRandom:

Public Types

enum  METHOD { SYSTEM , CRYPTO , UNIFORM_EXACT , DEFAULT = CRYPTO }
 Defines the random number generation method to use. More...
 

Public Member Functions

 CryptoRandom (METHOD method=METHOD.DEFAULT, int nSeed=0)
 The CryptoRandom constructor. More...
 
double NextDouble ()
 Returns a random double within the range $ [0, 1] $. More...
 
double NextDouble (double dfMin, double dfMax)
 Returns a random double within the range $ [dfMin, dfMax] $ More...
 
int Next (int nMinVal, int nMaxVal, bool bMaxInclusive=true)
 Returns a random int within the range $ [nMinVal, nMaxVal] $ More...
 
int Next ()
 Returns a random int within the range $ [0, int.MaxValue] $ More...
 
int Next (int nMaxVal)
 Returns a random int within the range $ [0, nMaxVal) $, where the random number is less than nMaxVal. More...
 

Detailed Description

The CryptoRandom is a random number generator that can use either the standard .Net Random objec or the more precise RandomNumberGenerator defined within the System.Security.Cryptograph.

Definition at line 13 of file CryptoRandom.cs.

Member Enumeration Documentation

◆ METHOD

Defines the random number generation method to use.

Enumerator
SYSTEM 

Uses the default Random object.

CRYPTO 

Uses the RandomNumberGenerator object.

See also
https://stackoverflow.com/questions/4892588/rngcryptoserviceprovider-random-number-review
UNIFORM_EXACT 

Only used with Next(nMaxVal) and returns exactly evenly selected numbers from the range [0, nMaxVal).

DEFAULT 

Specifies to use the default CRYPTO.

Definition at line 24 of file CryptoRandom.cs.

Constructor & Destructor Documentation

◆ CryptoRandom()

MyCaffe.basecode.CryptoRandom.CryptoRandom ( METHOD  method = METHOD.DEFAULT,
int  nSeed = 0 
)

The CryptoRandom constructor.

Parameters
methodSpecifies the random number generation method (default = CRYPTO1).
nSeedSpecifies the seed used to initialize the random number generator, only used when bUseCrypto = false (default = 0, which is ignored).

Definition at line 52 of file CryptoRandom.cs.

Member Function Documentation

◆ Next() [1/3]

int MyCaffe.basecode.CryptoRandom.Next ( )

Returns a random int within the range $ [0, int.MaxValue] $

Returns
The random int is returned.

Definition at line 130 of file CryptoRandom.cs.

◆ Next() [2/3]

int MyCaffe.basecode.CryptoRandom.Next ( int  nMaxVal)

Returns a random int within the range $ [0, nMaxVal) $, where the random number is less than nMaxVal.

Parameters
nMaxValSpecifies the non-inclusive maximum of the range.
Returns
The random int is returned.

Definition at line 140 of file CryptoRandom.cs.

◆ Next() [3/3]

int MyCaffe.basecode.CryptoRandom.Next ( int  nMinVal,
int  nMaxVal,
bool  bMaxInclusive = true 
)

Returns a random int within the range $ [nMinVal, nMaxVal] $

Parameters
nMinValSpecifies the range minimum.
nMaxValSpecifies the range maximum.
bMaxInclusiveOptionally, specifies whether or not the Maximum is to be included in the selection.
Returns
The random int is returned.

Definition at line 113 of file CryptoRandom.cs.

◆ NextDouble() [1/2]

double MyCaffe.basecode.CryptoRandom.NextDouble ( )

Returns a random double within the range $ [0, 1] $.

Returns
The random double is returned.

Definition at line 83 of file CryptoRandom.cs.

◆ NextDouble() [2/2]

double MyCaffe.basecode.CryptoRandom.NextDouble ( double  dfMin,
double  dfMax 
)

Returns a random double within the range $ [dfMin, dfMax] $

Parameters
dfMinSpecifies the range minimum.
dfMaxSpecifies the range maximum.
Returns
The random double is returned.

Definition at line 101 of file CryptoRandom.cs.


The documentation for this class was generated from the following file: