BGC Tools
Static Public Member Functions | Properties | Static Private Attributes
BGC.Mathematics.CustomRandom Class Reference
Collaboration diagram for BGC.Mathematics.CustomRandom:
Collaboration graph
[legend]

Static Public Member Functions

static double NextDouble ()
 Returns a random double in the range [0.0 1.0) More...
 
static float NextFloat ()
 Returns a random float in the range [0f 1f]. NOTE: 1 is inclusive, because of casting the double to a float rounding More...
 
static int Next ()
 Returns a random integer More...
 
static int Next (int min, int max)
 Returns a random integer in the range [min max) More...
 
static double RayleighDistribution (double input)
 Translates an evenly distributed random number in the range [0,1) into a Rayleigh-Distributed one. Technically in the range [0, 8.49151] due to the largest double less than one. About half the range of inputs results in a value less than 1, and 85% are less than 2. More...
 
static float RayleighDistribution (float input)
 Translates an evenly distributed random number in the range [0,1) into a Rayleigh-Distributed one. Technically in the range [0, 8.49151] due to the largest double less than one. About half the range of inputs results in a value less than 1, and 85% are less than 2. More...
 
static double NormalDistribution (double sigma, double mean, double input1, double input2)
 Returns a normally distributed value with specified mean and deviation More...
 
static double NormalDistribution (double input1, double input2)
 Returns a normally distributed value with mean 0 and sigma 1 https://en.wikipedia.org/wiki/Normal_distribution#Generating_values_from_normal_distribution More...
 
static float NextFloat (this Random random)
 Retrieve the next double and cast it to a float. More...
 

Properties

static Random GlobalRand [get]
 

Static Private Attributes

static object randLock = new object()
 Lock used to protect multi-thread access to random More...
 
static Random _globalRand
 

Detailed Description

Definition at line 7 of file CustomRandom.cs.

Member Function Documentation

◆ Next() [1/2]

static int BGC.Mathematics.CustomRandom.Next ( )
inlinestatic

◆ Next() [2/2]

static int BGC.Mathematics.CustomRandom.Next ( int  min,
int  max 
)
inlinestatic

Returns a random integer in the range [min max)

Definition at line 65 of file CustomRandom.cs.

66  {
67  lock (randLock)
68  {
69  return GlobalRand.Next(min, max);
70  }
71  }
static object randLock
Lock used to protect multi-thread access to random
Definition: CustomRandom.cs:12

◆ NextDouble()

static double BGC.Mathematics.CustomRandom.NextDouble ( )
inlinestatic

Returns a random double in the range [0.0 1.0)

Definition at line 31 of file CustomRandom.cs.

32  {
33  lock (randLock)
34  {
35  return GlobalRand.NextDouble();
36  }
37  }
static object randLock
Lock used to protect multi-thread access to random
Definition: CustomRandom.cs:12

◆ NextFloat() [1/2]

static float BGC.Mathematics.CustomRandom.NextFloat ( )
inlinestatic

Returns a random float in the range [0f 1f]. NOTE: 1 is inclusive, because of casting the double to a float rounding

Definition at line 43 of file CustomRandom.cs.

44  {
45  lock (randLock)
46  {
47  return GlobalRand.NextFloat();
48  }
49  }
static object randLock
Lock used to protect multi-thread access to random
Definition: CustomRandom.cs:12

◆ NextFloat() [2/2]

static float BGC.Mathematics.CustomRandom.NextFloat ( this Random  random)
static

Retrieve the next double and cast it to a float.

Parameters
random
Returns

◆ NormalDistribution() [1/2]

static double BGC.Mathematics.CustomRandom.NormalDistribution ( double  sigma,
double  mean,
double  input1,
double  input2 
)
static

Returns a normally distributed value with specified mean and deviation

◆ NormalDistribution() [2/2]

static double BGC.Mathematics.CustomRandom.NormalDistribution ( double  input1,
double  input2 
)
static

Returns a normally distributed value with mean 0 and sigma 1 https://en.wikipedia.org/wiki/Normal_distribution#Generating_values_from_normal_distribution

◆ RayleighDistribution() [1/2]

static double BGC.Mathematics.CustomRandom.RayleighDistribution ( double  input)
static

Translates an evenly distributed random number in the range [0,1) into a Rayleigh-Distributed one. Technically in the range [0, 8.49151] due to the largest double less than one. About half the range of inputs results in a value less than 1, and 85% are less than 2.

Parameters
inputRandom input value. Should be in range [0 1]

Referenced by BGC.Audio.Synthesis.NoiseAudioClip.CreateSideBands(), BGC.Audio.AnalyticStreams.AnalyticNoiseStream.CreateSideBands(), BGC.Audio.Synthesis.STMAudioClip.CreateSideBands(), and BGC.Tests.SynthesisTests.TestFDComposer().

Here is the caller graph for this function:

◆ RayleighDistribution() [2/2]

static float BGC.Mathematics.CustomRandom.RayleighDistribution ( float  input)
static

Translates an evenly distributed random number in the range [0,1) into a Rayleigh-Distributed one. Technically in the range [0, 8.49151] due to the largest double less than one. About half the range of inputs results in a value less than 1, and 85% are less than 2.

Parameters
inputRandom input value. Should be in range [0 1]

Field Documentation

◆ _globalRand

Random BGC.Mathematics.CustomRandom._globalRand
staticprivate

Definition at line 14 of file CustomRandom.cs.

◆ randLock

object BGC.Mathematics.CustomRandom.randLock = new object()
staticprivate

Lock used to protect multi-thread access to random

Definition at line 12 of file CustomRandom.cs.

Property Documentation

◆ GlobalRand

Random BGC.Mathematics.CustomRandom.GlobalRand
staticgetprivate

Definition at line 16 of file CustomRandom.cs.


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