Package gov.nih.mipav.model.algorithms
Class RandomNumberGen
java.lang.Object
java.util.Random
gov.nih.mipav.model.algorithms.RandomNumberGen
- All Implemented Interfaces:
Serializable,java.util.random.RandomGenerator
Algorithm that produces a random number (Gaussian or uniform) in a specific user/programmer defined range.
- Version:
- 0.1 May 4, 1998
- Author:
- Matthew J. McAuliffe, Ph.D.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
java.util.random.RandomGenerator.ArbitrarilyJumpableGenerator, java.util.random.RandomGenerator.JumpableGenerator, java.util.random.RandomGenerator.LeapableGenerator, java.util.random.RandomGenerator.SplittableGenerator, java.util.random.RandomGenerator.StreamableGenerator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final longUse serialVersionUID for interoperability. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final longfactorial(int number) Returns the factorial of a nonnegative integer.final doublegenGaussianRandomNum(double stRange, double endRange) Generates a Gaussian random number greater or equal to the stRange and less than or equal to the endRange.final floatgenGaussianRandomNum(float stRange, float endRange) Generates a Gaussian random number greater or equal to the stRange and less than or equal to the endRange.final intgenGaussianRandomNum(int stRange, int endRange) Generates a Gaussian random number greater or equal to the stRange and less than or equal to the endRange.final doublefinal doublegenUniformRandomNum(double stRange, double endRange) Generates a uniform random number greater or equal to the stRange and less than or equal to the endRange.final floatgenUniformRandomNum(float stRange, float endRange) Generates a uniform random number greater or equal to the stRange and less than or equal to the endRange.final intgenUniformRandomNum(int stRange, int endRange) Generates a uniform random number greater or equal to the stRange and less than or equal to the endRange.final double[]poissDecay(int nEvents, double mu, double gain, double offset) This code is derived from PoissDecay.cpp, PoissonDeviate, PoissonRecur, and RandomDeviate, code accompanying Data Reduction and Error Analysis for the Physical Sciences, Third Edition, by Philip R.Methods inherited from class java.util.Random
doubles, doubles, doubles, doubles, from, ints, ints, ints, ints, longs, longs, longs, longs, next, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.random.RandomGenerator
isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDUse serialVersionUID for interoperability.- See Also:
-
-
Constructor Details
-
RandomNumberGen
public RandomNumberGen()RandomNumberGen - constructor.
-
-
Method Details
-
factorial
public static final long factorial(int number) Returns the factorial of a nonnegative integer.- Parameters:
number- integer whose factorial is being returned- Returns:
- number!
-
genGaussianRandomNum
public final int genGaussianRandomNum(int stRange, int endRange) Generates a Gaussian random number greater or equal to the stRange and less than or equal to the endRange.- Parameters:
stRange- the random number will be greater than or equal to this numberendRange- the random number will be less than or equal to this number- Returns:
- integer number in the range
-
genGaussianRandomNum
public final float genGaussianRandomNum(float stRange, float endRange) Generates a Gaussian random number greater or equal to the stRange and less than or equal to the endRange.- Parameters:
stRange- the random number will be greater than or equal to this numberendRange- the random number will be less than or equal to this number- Returns:
- float number in the range
-
genGaussianRandomNum
public final double genGaussianRandomNum(double stRange, double endRange) Generates a Gaussian random number greater or equal to the stRange and less than or equal to the endRange.- Parameters:
stRange- the random number will be greater than or equal to this numberendRange- the random number will be less than or equal to this number- Returns:
- float number in the range
-
genStandardGaussian
public final double genStandardGaussian() -
genUniformRandomNum
public final int genUniformRandomNum(int stRange, int endRange) Generates a uniform random number greater or equal to the stRange and less than or equal to the endRange.- Parameters:
stRange- the random number will be greater than or equal to this numberendRange- the random number will be less than or equal to this number- Returns:
- integer number in the range
-
genUniformRandomNum
public final float genUniformRandomNum(float stRange, float endRange) Generates a uniform random number greater or equal to the stRange and less than or equal to the endRange.- Parameters:
stRange- the random number will be greater than or equal to this numberendRange- the random number will be less than or equal to this number- Returns:
- float number in the range
-
genUniformRandomNum
public final double genUniformRandomNum(double stRange, double endRange) Generates a uniform random number greater or equal to the stRange and less than or equal to the endRange.- Parameters:
stRange- the random number will be greater than or equal to this numberendRange- the random number will be less than or equal to this number- Returns:
- float number in the range
-
poissDecay
public final double[] poissDecay(int nEvents, double mu, double gain, double offset) This code is derived from PoissDecay.cpp, PoissonDeviate, PoissonRecur, and RandomDeviate, code accompanying Data Reduction and Error Analysis for the Physical Sciences, Third Edition, by Philip R. Bevington and D. Keith Robinson p(x, u)is the probability of observing x events where u is the average number of events observed. x must be zero or a positive integer. p(x, u) = (u**x)* exp(-u)/x! The sum of x from 0 to infinity of p(x, u) = 1. mean value of x = u variance of x = u Return gain * p(x, u) + offset- Parameters:
nEvents-mu- mean of Poisson distribtuiongain-offset-- Returns:
-