Class RandomNumberGen

java.lang.Object
java.util.Random
gov.nih.mipav.model.algorithms.RandomNumberGen
All Implemented Interfaces:
Serializable, java.util.random.RandomGenerator

public class RandomNumberGen extends Random
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

    Fields
    Modifier and Type
    Field
    Description
    private static final long
    Use serialVersionUID for interoperability.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RandomNumberGen - constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static final long
    factorial(int number)
    Returns the factorial of a nonnegative integer.
    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.
    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.
    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.
    final double
     
    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.
    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.
    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.
    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.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.random.RandomGenerator

    isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextGaussian, nextInt, nextLong, nextLong
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use 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 number
      endRange - 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 number
      endRange - 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 number
      endRange - 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 number
      endRange - 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 number
      endRange - 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 number
      endRange - 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 distribtuion
      gain -
      offset -
      Returns: