Package com.irurueta.statistics
Class GaussianRandomizer
java.lang.Object
com.irurueta.statistics.Randomizer
com.irurueta.statistics.GaussianRandomizer
Generates pseudo-random values following a Gaussian distribution having
 the specified mMean and standard deviation. By default, mMean is equal to
 DEFAULT_MEAN and the standard deviation is equal to
 DEFAULT_STANDARD_DEVIATION.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final doubleSpecifies mMean value to be used for random value generation if no mMean is provided.static final doubleSpecifies standard deviation to be used for random value generation if none is provided.private doubleContains mMean value to be used for random value generation.private doubleStandard deviation value to be used for random value generation.Fields inherited from class com.irurueta.statistics.RandomizerDEFAULT_RANDOMIZER_TYPE, USE_SECURE_RANDOM_BY_DEFAULT
- 
Constructor SummaryConstructorsConstructorDescriptionConstructor.GaussianRandomizer(double mean, double standardDeviation) Constructor.GaussianRandomizer(Random internalRandom) Constructor.GaussianRandomizer(Random internalRandom, double mean, double standardDeviation) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionvoidfill(boolean[] array, double threshold) Fills provided array with random booleans where the probability of returning true is equal to obtaining a Gaussian value below the provided threshold, which is equal to erfc function.doublegetMean()Returns mMean value to be used for Gaussian random value generation.doubleReturns standard deviation to be used for Gaussian random value generation.getType()Returns the randomizer type of this instance.booleanReturns next random boolean value.booleannextBoolean(double threshold) Returns next random boolean value.boolean[]nextBooleans(int length, double threshold) Returns array of booleans having provided length and containing random boolean values.doubleReturns next random Gaussian double precision floating-point value having provided mMean and standard deviation.floatReturns next random Gaussian floating-point value having provided mMean and standard deviation.intnextInt()Returns next random Gaussian integer value having provided mMean and standard deviation.longnextLong()Returns next random Gaussian long value having provided mMean and standard deviation.voidsetMean(double mean) Sets mMean value to be used for Gaussian random value generation.voidsetStandardDeviation(double standardDeviation) Sets standard deviation to be used for Gaussian random value generation.Methods inherited from class com.irurueta.statistics.Randomizercreate, create, create, create, create, create, fill, fill, fill, fill, fill, getInternalRandom, nextBooleans, nextDoubles, nextFloats, nextInts, nextLongs, setInternalRandom, setSeed
- 
Field Details- 
DEFAULT_MEANpublic static final double DEFAULT_MEANSpecifies mMean value to be used for random value generation if no mMean is provided.- See Also:
 
- 
DEFAULT_STANDARD_DEVIATIONpublic static final double DEFAULT_STANDARD_DEVIATIONSpecifies standard deviation to be used for random value generation if none is provided.- See Also:
 
- 
meanprivate double meanContains mMean value to be used for random value generation.
- 
standardDeviationprivate double standardDeviationStandard deviation value to be used for random value generation.
 
- 
- 
Constructor Details- 
GaussianRandomizerpublic GaussianRandomizer()Constructor. Uses defaultRandomimplementation.
- 
GaussianRandomizerpublic GaussianRandomizer(double mean, double standardDeviation) Constructor. Uses defaultRandomimplementation.- Parameters:
- mean- Mean value of generated Gaussian values.
- standardDeviation- Standard deviation of generated Gaussian values.
- Throws:
- IllegalArgumentException- thrown if provided standard deviation is negative or zero.
- NullPointerException- if provided internal Random instance is null.
 
- 
GaussianRandomizerConstructor. Because neither mMean nor standard deviation are provided, values DEFAULT_MEAN and DEFAULT_STANDARD_DEVIATION will be used instead.- Parameters:
- internalRandom- Internal Random instance in charge of generating pseudo-random values.
- Throws:
- NullPointerException- thrown if provided internal random is null.
 
- 
GaussianRandomizerConstructor.- Parameters:
- internalRandom- Internal Random instance if charge of generating pseudo-random values.
- mean- Mean value of generated Gaussian values.
- standardDeviation- Standard deviation of generated Gaussian values.
- Throws:
- IllegalArgumentException- thrown if provided standard deviation is negative or zero.
- NullPointerException- if provided internal Random instance is null.
 
 
- 
- 
Method Details- 
getMeanpublic double getMean()Returns mMean value to be used for Gaussian random value generation.- Returns:
- Mean value.
 
- 
setMeanpublic void setMean(double mean) Sets mMean value to be used for Gaussian random value generation.- Parameters:
- mean- Mean value.
 
- 
getStandardDeviationpublic double getStandardDeviation()Returns standard deviation to be used for Gaussian random value generation.- Returns:
- Standard deviation.
 
- 
setStandardDeviationpublic void setStandardDeviation(double standardDeviation) Sets standard deviation to be used for Gaussian random value generation.- Parameters:
- standardDeviation- Standard deviation.
- Throws:
- IllegalArgumentException- exception thrown if provided standard deviation is negative or zero.
 
- 
nextBooleanpublic boolean nextBoolean()Returns next random boolean value. The probability of returning true is equal to obtaining a Gaussian value below the mMean, which is 50%.- Specified by:
- nextBooleanin class- Randomizer
- Returns:
- Next boolean value.
 
- 
nextBooleanpublic boolean nextBoolean(double threshold) Returns next random boolean value. The probability of returning true is equal to obtaining a Gaussian value below the provided threshold, which is equal to erfc function.- Parameters:
- threshold- Threshold to determine whether returned values will be true or false.
- Returns:
- Next random boolean value.
 
- 
fillpublic void fill(boolean[] array, double threshold) Fills provided array with random booleans where the probability of returning true is equal to obtaining a Gaussian value below the provided threshold, which is equal to erfc function.- Parameters:
- array- array to be filled.
- threshold- Threshold to determine whether generated values will be true or false.
 
- 
nextBooleanspublic boolean[] nextBooleans(int length, double threshold) Returns array of booleans having provided length and containing random boolean values. The probability of returning true is equal to obtaining a Gaussian value below the provided threshold, which is equal to erfc function.- Parameters:
- length- Length of array to be created.
- threshold- Threshold to determine whether returned values will be true or false.
- Returns:
- Array of random booleans.
- Throws:
- IllegalArgumentException- if provided length is zero or negative.
 
- 
nextIntpublic int nextInt()Returns next random Gaussian integer value having provided mMean and standard deviation.- Specified by:
- nextIntin class- Randomizer
- Returns:
- Next random Gaussian integer value.
 
- 
nextLongpublic long nextLong()Returns next random Gaussian long value having provided mMean and standard deviation.- Specified by:
- nextLongin class- Randomizer
- Returns:
- Next random Gaussian long value.
 
- 
nextFloatpublic float nextFloat()Returns next random Gaussian floating-point value having provided mMean and standard deviation.- Specified by:
- nextFloatin class- Randomizer
- Returns:
- Next random Gaussian floating-point value.
 
- 
nextDoublepublic double nextDouble()Returns next random Gaussian double precision floating-point value having provided mMean and standard deviation.- Specified by:
- nextDoublein class- Randomizer
- Returns:
- Next random Gaussian double precision floating-point value.
 
- 
getTypeReturns the randomizer type of this instance.- Specified by:
- getTypein class- Randomizer
- Returns:
- Randomizer type.
 
 
-