Class DefaultRandomRegistry

java.lang.Object
repast.simphony.random.DefaultRandomRegistry
All Implemented Interfaces:
RandomRegistry

public class DefaultRandomRegistry extends Object implements RandomRegistry
A registry that stores random number generators.
Author:
Jerry Vos
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     

    Fields inherited from interface repast.simphony.random.RandomRegistry

    DEFAULT_GENERATOR
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    cern.jet.random.Beta
    createBeta(double alpha, double beta)
    Creates the default beta distribution using the default random number generator.
    cern.jet.random.Binomial
    createBinomial(int n, double p)
    Creates the default binomial distribution using the default random number generator.
    cern.jet.random.BreitWigner
    createBreitWigner(double mean, double gamma, double cut)
    Creates the default Breit Wigner distribution using the default random number generator.
    cern.jet.random.BreitWignerMeanSquare
    createBreitWignerMeanSquareState(double mean, double gamma, double cut)
    Creates the default Breit Wigner mean square state distribution using the default random number generator.
    cern.jet.random.ChiSquare
    createChiSquare(double freedom)
    Creates the default chi square distribution using the default random number generator.
    cern.jet.random.Empirical
    createEmpirical(double[] pdf, int interpolationType)
    Creates the default empirical distribution using the default random number generator.
    cern.jet.random.EmpiricalWalker
    createEmpiricalWalker(double[] pdf, int interpolationType)
    Creates the default empirical walker distribution using the default random number generator.
    cern.jet.random.Exponential
    createExponential(double lambda)
    Creates the default exponential distribution using the default random number generator.
    cern.jet.random.ExponentialPower
    Creates the default exponential power distribution using the default random number generator.
    cern.jet.random.Gamma
    createGamma(double alpha, double lambda)
    Creates the default gamma distribution using the default random number generator.
    cern.jet.random.Hyperbolic
    createHyperbolic(double alpha, double beta)
    Creates the default hyperbolic distribution using the default random number generator.
    cern.jet.random.HyperGeometric
    createHyperGeometric(int N, int s, int n)
    Creates the default hyper geometric distribution using the default random number generator.
    cern.jet.random.Logarithmic
    Creates the default logarithmic distribution using the default random number generator.
    cern.jet.random.NegativeBinomial
    createNegativeBinomial(int n, double p)
    Creates the default negative binomial distribution using the default random number generator.
    cern.jet.random.Normal
    createNormal(double mean, double standardDeviation)
    Creates the default normal distribution using the default random number generator.
    cern.jet.random.Poisson
    createPoisson(double mean)
    Creates the default Poisson distribution using the default random number generator.
    cern.jet.random.PoissonSlow
    createPoissonSlow(double mean)
    Creates the default slower Poisson distribution using the default random number generator.
    cern.jet.random.StudentT
    createStudentT(double freedom)
    Creates the default StudentT distribution using the default random number generator.
    cern.jet.random.Uniform
    Creates the default Unifrom distribution using the default random number generator.
    cern.jet.random.Uniform
    createUniform(double min, double max)
    Creates the default uniform distribution using the default random number generator.
    cern.jet.random.VonMises
    createVonMises(double freedom)
    Creates a default VonMises distribution using the default random number generator.
    cern.jet.random.Zeta
    createZeta(double ro, double pk)
    Creates the default Zeta distribution using the default random number generator.
    cern.jet.random.Beta
    Gets the default beta distribution.
    cern.jet.random.Binomial
    Gets the default binomial distribution.
    cern.jet.random.BreitWigner
    Gets the default BreitWigner distribution.
    cern.jet.random.BreitWignerMeanSquare
    Gets the default BreitWignerMeanSquare distribution.
    cern.jet.random.ChiSquare
    Gets the default Zeta distribution.
    cern.jet.random.AbstractDistribution
    Gets the named previously registered distribution.
    cern.jet.random.Empirical
    Gets the default ChiSquare distribution.
    cern.jet.random.EmpiricalWalker
    Gets the default EmpiricalWalker distribution.
    cern.jet.random.Exponential
    Gets the default Exponential distribution.
    cern.jet.random.ExponentialPower
    Gets the default exponentialPower distribution.
    cern.jet.random.Gamma
    Gets the default gamma distribution.
    cern.jet.random.engine.RandomEngine
    getGenerator(String generatorName)
    Gets a previously registered random number generator.
    cern.jet.random.Hyperbolic
    Gets the default hyperbolic distribution.
    cern.jet.random.HyperGeometric
    Gets the default hyperGeometric distribution.
    cern.jet.random.Logarithmic
    Gets the default logarithmic distribution.
    cern.jet.random.NegativeBinomial
    Gets the default negativeBinomial distribution.
    cern.jet.random.Normal
    Gets the default normal distribution.
    cern.jet.random.Poisson
    Gets the default poisson distribution.
    cern.jet.random.PoissonSlow
    Gets the default slow poisson distribution.
    int
    getSeed(String generatorName)
    Gets the seed of the named generator.
    cern.jet.random.StudentT
    Gets the default studentT distribution.
    cern.jet.random.Uniform
    Gets the default uniform distribution.
    cern.jet.random.VonMises
    Gets the default vonMises distribution.
    cern.jet.random.Zeta
    Gets the default Zeta distribution.
    void
    registerDistribution(String name, cern.jet.random.AbstractDistribution dist)
    Registers the named random number distribution for later retrieval.
    cern.jet.random.engine.RandomEngine
    registerGenerator(String name, int seed)
    Creates and registers a new random number generator with the specified name and seed.
    void
    Resets this random registry by doing the following: invalidates any live default distributions removes (de-registers) any non-default distributions removes (de-registers) any non-default random number generators creates a new default random number generator with the current time as its seed creates a new default uniform distributions
    void
    setSeed(int seed)
    Sets the seed for the default random number generator.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • defaultSeed

      protected int defaultSeed
  • Constructor Details

    • DefaultRandomRegistry

      public DefaultRandomRegistry()
      Default constructor
  • Method Details

    • registerGenerator

      public cern.jet.random.engine.RandomEngine registerGenerator(String name, int seed)
      Creates and registers a new random number generator with the specified name and seed. The generator can then be retrieved later using #getGenerator(String).

      This will create a MersenneTwister for the generator.

      Specified by:
      registerGenerator in interface RandomRegistry
      Parameters:
      name - the name of the generator to create and register
      seed - the new generators seed
      Returns:
      the new generator itself
    • getGenerator

      public cern.jet.random.engine.RandomEngine getGenerator(String generatorName)
      Gets a previously registered random number generator.
      Specified by:
      getGenerator in interface RandomRegistry
      Parameters:
      generatorName - the name of the generator to get
      Returns:
      a previously registered random number generator.
    • getSeed

      public int getSeed(String generatorName)
      Gets the seed of the named generator.
      Specified by:
      getSeed in interface RandomRegistry
      Parameters:
      generatorName - the name of the generator
      Returns:
      the seed of the named generator.
    • registerDistribution

      public void registerDistribution(String name, cern.jet.random.AbstractDistribution dist)
      Registers the named random number distribution for later retrieval.
      Specified by:
      registerDistribution in interface RandomRegistry
      Parameters:
      name - the name of the distribution
      dist - the distribution to register
    • getDistribution

      public cern.jet.random.AbstractDistribution getDistribution(String name)
      Gets the named previously registered distribution. Calling code can then cast the distribution into the appropriate type (e.g. a Normal).
      Specified by:
      getDistribution in interface RandomRegistry
      Parameters:
      name - the name of the distribution to get
      Returns:
      the named previously registered distribution.
    • createZeta

      public cern.jet.random.Zeta createZeta(double ro, double pk)
      Creates the default Zeta distribution using the default random number generator.
      Specified by:
      createZeta in interface RandomRegistry
      Parameters:
      ro -
      pk -
      Returns:
      the created distribution
    • getZeta

      public cern.jet.random.Zeta getZeta()
      Gets the default Zeta distribution.
      Specified by:
      getZeta in interface RandomRegistry
      Returns:
      the default Zeta distribution.
    • createVonMises

      public cern.jet.random.VonMises createVonMises(double freedom)
      Creates a default VonMises distribution using the default random number generator.
      Specified by:
      createVonMises in interface RandomRegistry
      Parameters:
      freedom -
      Returns:
      the created distribution
    • createUniform

      public cern.jet.random.Uniform createUniform(double min, double max)
      Creates the default uniform distribution using the default random number generator.
      Specified by:
      createUniform in interface RandomRegistry
      Parameters:
      min -
      max -
      Returns:
      the created distribution
    • createUniform

      public cern.jet.random.Uniform createUniform()
      Creates the default Unifrom distribution using the default random number generator.
      Specified by:
      createUniform in interface RandomRegistry
      Returns:
      the created distribution
    • createStudentT

      public cern.jet.random.StudentT createStudentT(double freedom)
      Creates the default StudentT distribution using the default random number generator.
      Specified by:
      createStudentT in interface RandomRegistry
      Parameters:
      freedom -
      Returns:
      the created distribution
    • createPoissonSlow

      public cern.jet.random.PoissonSlow createPoissonSlow(double mean)
      Creates the default slower Poisson distribution using the default random number generator.
      Specified by:
      createPoissonSlow in interface RandomRegistry
      Parameters:
      mean -
      Returns:
      the created distribution
    • createPoisson

      public cern.jet.random.Poisson createPoisson(double mean)
      Creates the default Poisson distribution using the default random number generator.
      Specified by:
      createPoisson in interface RandomRegistry
      Parameters:
      mean -
      Returns:
      the created distribution
    • createNormal

      public cern.jet.random.Normal createNormal(double mean, double standardDeviation)
      Creates the default normal distribution using the default random number generator.
      Specified by:
      createNormal in interface RandomRegistry
      Parameters:
      mean -
      standardDeviation -
      Returns:
      the created distribution
    • createNegativeBinomial

      public cern.jet.random.NegativeBinomial createNegativeBinomial(int n, double p)
      Creates the default negative binomial distribution using the default random number generator.
      Specified by:
      createNegativeBinomial in interface RandomRegistry
      Parameters:
      n -
      p -
      Returns:
      the created distribution
    • createLogarithmic

      public cern.jet.random.Logarithmic createLogarithmic(double p)
      Creates the default logarithmic distribution using the default random number generator.
      Specified by:
      createLogarithmic in interface RandomRegistry
      Parameters:
      p -
      Returns:
      the created distribution
    • createHyperGeometric

      public cern.jet.random.HyperGeometric createHyperGeometric(int N, int s, int n)
      Creates the default hyper geometric distribution using the default random number generator.
      Specified by:
      createHyperGeometric in interface RandomRegistry
      Parameters:
      N -
      s -
      n -
      Returns:
      the created distribution
    • createHyperbolic

      public cern.jet.random.Hyperbolic createHyperbolic(double alpha, double beta)
      Creates the default hyperbolic distribution using the default random number generator.
      Specified by:
      createHyperbolic in interface RandomRegistry
      Parameters:
      alpha -
      beta -
      Returns:
      the created distribution
    • createGamma

      public cern.jet.random.Gamma createGamma(double alpha, double lambda)
      Creates the default gamma distribution using the default random number generator.
      Specified by:
      createGamma in interface RandomRegistry
      Parameters:
      alpha -
      lambda -
      Returns:
      the created distribution
    • createExponentialPower

      public cern.jet.random.ExponentialPower createExponentialPower(double tau)
      Creates the default exponential power distribution using the default random number generator.
      Specified by:
      createExponentialPower in interface RandomRegistry
      Parameters:
      tau -
      Returns:
      the created distribution
    • createExponential

      public cern.jet.random.Exponential createExponential(double lambda)
      Creates the default exponential distribution using the default random number generator.
      Specified by:
      createExponential in interface RandomRegistry
      Parameters:
      lambda -
      Returns:
      the created distribution
    • createEmpiricalWalker

      public cern.jet.random.EmpiricalWalker createEmpiricalWalker(double[] pdf, int interpolationType)
      Creates the default empirical walker distribution using the default random number generator.
      Specified by:
      createEmpiricalWalker in interface RandomRegistry
      Parameters:
      pdf -
      interpolationType -
      Returns:
      the created distribution
    • createEmpirical

      public cern.jet.random.Empirical createEmpirical(double[] pdf, int interpolationType)
      Creates the default empirical distribution using the default random number generator.
      Specified by:
      createEmpirical in interface RandomRegistry
      Parameters:
      pdf -
      interpolationType -
      Returns:
      the created distribution
    • createChiSquare

      public cern.jet.random.ChiSquare createChiSquare(double freedom)
      Creates the default chi square distribution using the default random number generator.
      Specified by:
      createChiSquare in interface RandomRegistry
      Parameters:
      freedom -
      Returns:
      the created distribution
    • createBreitWignerMeanSquareState

      public cern.jet.random.BreitWignerMeanSquare createBreitWignerMeanSquareState(double mean, double gamma, double cut)
      Creates the default Breit Wigner mean square state distribution using the default random number generator.
      Specified by:
      createBreitWignerMeanSquareState in interface RandomRegistry
      Parameters:
      mean -
      gamma -
      cut -
      Returns:
      the created distribution
    • createBreitWigner

      public cern.jet.random.BreitWigner createBreitWigner(double mean, double gamma, double cut)
      Creates the default Breit Wigner distribution using the default random number generator.
      Specified by:
      createBreitWigner in interface RandomRegistry
      Parameters:
      mean -
      gamma -
      cut -
      Returns:
      the created distribution
    • createBinomial

      public cern.jet.random.Binomial createBinomial(int n, double p)
      Creates the default binomial distribution using the default random number generator.
      Specified by:
      createBinomial in interface RandomRegistry
      Parameters:
      n -
      p -
    • createBeta

      public cern.jet.random.Beta createBeta(double alpha, double beta)
      Creates the default beta distribution using the default random number generator.
      Specified by:
      createBeta in interface RandomRegistry
      Parameters:
      alpha -
      beta -
      Returns:
      the created distribution
    • getBeta

      public cern.jet.random.Beta getBeta()
      Gets the default beta distribution.
      Specified by:
      getBeta in interface RandomRegistry
      Returns:
      the default beta distribution.
    • getBinomial

      public cern.jet.random.Binomial getBinomial()
      Gets the default binomial distribution.
      Specified by:
      getBinomial in interface RandomRegistry
      Returns:
      the default binomial distribution.
    • getBreitWigner

      public cern.jet.random.BreitWigner getBreitWigner()
      Gets the default BreitWigner distribution.
      Specified by:
      getBreitWigner in interface RandomRegistry
      Returns:
      the default BreitWigner distribution.
    • getBreitWignerMeanSquare

      public cern.jet.random.BreitWignerMeanSquare getBreitWignerMeanSquare()
      Gets the default BreitWignerMeanSquare distribution.
      Specified by:
      getBreitWignerMeanSquare in interface RandomRegistry
      Returns:
      the default BreitWignerMeanSquare distribution.
    • getChiSquare

      public cern.jet.random.ChiSquare getChiSquare()
      Gets the default Zeta distribution.
      Specified by:
      getChiSquare in interface RandomRegistry
      Returns:
      the default Zeta distribution.
    • getEmpirical

      public cern.jet.random.Empirical getEmpirical()
      Gets the default ChiSquare distribution.
      Specified by:
      getEmpirical in interface RandomRegistry
      Returns:
      the default ChiSquare distribution.
    • getEmpiricalWalker

      public cern.jet.random.EmpiricalWalker getEmpiricalWalker()
      Gets the default EmpiricalWalker distribution.
      Specified by:
      getEmpiricalWalker in interface RandomRegistry
      Returns:
      the default EmpiricalWalker distribution.
    • getExponential

      public cern.jet.random.Exponential getExponential()
      Gets the default Exponential distribution.
      Specified by:
      getExponential in interface RandomRegistry
      Returns:
      the default Exponential distribution.
    • getExponentialPower

      public cern.jet.random.ExponentialPower getExponentialPower()
      Gets the default exponentialPower distribution.
      Specified by:
      getExponentialPower in interface RandomRegistry
      Returns:
      the default exponentialPower distribution.
    • getGamma

      public cern.jet.random.Gamma getGamma()
      Gets the default gamma distribution.
      Specified by:
      getGamma in interface RandomRegistry
      Returns:
      the default gamma distribution.
    • getHyperbolic

      public cern.jet.random.Hyperbolic getHyperbolic()
      Gets the default hyperbolic distribution.
      Specified by:
      getHyperbolic in interface RandomRegistry
      Returns:
      the default hyperbolic distribution.
    • getHyperGeometric

      public cern.jet.random.HyperGeometric getHyperGeometric()
      Gets the default hyperGeometric distribution.
      Specified by:
      getHyperGeometric in interface RandomRegistry
      Returns:
      the default hyperGeometric distribution.
    • getLogarithmic

      public cern.jet.random.Logarithmic getLogarithmic()
      Gets the default logarithmic distribution.
      Specified by:
      getLogarithmic in interface RandomRegistry
      Returns:
      the default logarithmic distribution.
    • getNegativeBinomial

      public cern.jet.random.NegativeBinomial getNegativeBinomial()
      Gets the default negativeBinomial distribution.
      Specified by:
      getNegativeBinomial in interface RandomRegistry
      Returns:
      the default negativeBinomial distribution.
    • getNormal

      public cern.jet.random.Normal getNormal()
      Gets the default normal distribution.
      Specified by:
      getNormal in interface RandomRegistry
      Returns:
      the default normal distribution.
    • getPoisson

      public cern.jet.random.Poisson getPoisson()
      Gets the default poisson distribution.
      Specified by:
      getPoisson in interface RandomRegistry
      Returns:
      the default poisson distribution.
    • getPoissonSlow

      public cern.jet.random.PoissonSlow getPoissonSlow()
      Gets the default slow poisson distribution.
      Specified by:
      getPoissonSlow in interface RandomRegistry
      Returns:
      the default slow poisson distribution.
    • getStudentT

      public cern.jet.random.StudentT getStudentT()
      Gets the default studentT distribution.
      Specified by:
      getStudentT in interface RandomRegistry
      Returns:
      the default studentT distribution.
    • getUniform

      public cern.jet.random.Uniform getUniform()
      Gets the default uniform distribution.
      Specified by:
      getUniform in interface RandomRegistry
      Returns:
      the default uniform distribution.
    • getVonMises

      public cern.jet.random.VonMises getVonMises()
      Gets the default vonMises distribution.
      Specified by:
      getVonMises in interface RandomRegistry
      Returns:
      the default vonMises distribution.
    • setSeed

      public void setSeed(int seed)
      Sets the seed for the default random number generator. Any previously created default distributions will be invalidated.
      Specified by:
      setSeed in interface RandomRegistry
      Parameters:
      seed - the new seed
    • reset

      public void reset()
      Resets this random registry by doing the following:
      1. invalidates any live default distributions
      2. removes (de-registers) any non-default distributions
      3. removes (de-registers) any non-default random number generators
      4. creates a new default random number generator with the current time as its seed
      5. creates a new default uniform distributions
      Specified by:
      reset in interface RandomRegistry