Package repast.simphony.random
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
defaultSeed
-
Fields inherited from interface repast.simphony.random.RandomRegistry
DEFAULT_GENERATOR
-
-
Constructor Summary
Constructors Constructor Description DefaultRandomRegistry()
Default constructor
-
Method Summary
All Methods Instance Methods Concrete Methods 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
createExponentialPower(double tau)
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
createLogarithmic(double p)
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
createUniform()
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
getBeta()
Gets the default beta distribution.cern.jet.random.Binomial
getBinomial()
Gets the default binomial distribution.cern.jet.random.BreitWigner
getBreitWigner()
Gets the default BreitWigner distribution.cern.jet.random.BreitWignerMeanSquare
getBreitWignerMeanSquare()
Gets the default BreitWignerMeanSquare distribution.cern.jet.random.ChiSquare
getChiSquare()
Gets the default Zeta distribution.cern.jet.random.AbstractDistribution
getDistribution(String name)
Gets the named previously registered distribution.cern.jet.random.Empirical
getEmpirical()
Gets the default ChiSquare distribution.cern.jet.random.EmpiricalWalker
getEmpiricalWalker()
Gets the default EmpiricalWalker distribution.cern.jet.random.Exponential
getExponential()
Gets the default Exponential distribution.cern.jet.random.ExponentialPower
getExponentialPower()
Gets the default exponentialPower distribution.cern.jet.random.Gamma
getGamma()
Gets the default gamma distribution.cern.jet.random.engine.RandomEngine
getGenerator(String generatorName)
Gets a previously registered random number generator.cern.jet.random.Hyperbolic
getHyperbolic()
Gets the default hyperbolic distribution.cern.jet.random.HyperGeometric
getHyperGeometric()
Gets the default hyperGeometric distribution.cern.jet.random.Logarithmic
getLogarithmic()
Gets the default logarithmic distribution.cern.jet.random.NegativeBinomial
getNegativeBinomial()
Gets the default negativeBinomial distribution.cern.jet.random.Normal
getNormal()
Gets the default normal distribution.cern.jet.random.Poisson
getPoisson()
Gets the default poisson distribution.cern.jet.random.PoissonSlow
getPoissonSlow()
Gets the default slow poisson distribution.int
getSeed(String generatorName)
Gets the seed of the named generator.cern.jet.random.StudentT
getStudentT()
Gets the default studentT distribution.cern.jet.random.Uniform
getUniform()
Gets the default uniform distribution.cern.jet.random.VonMises
getVonMises()
Gets the default vonMises distribution.cern.jet.random.Zeta
getZeta()
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
reset()
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 distributionsvoid
setSeed(int seed)
Sets the seed for the default random number generator.
-
-
-
Method Detail
-
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 interfaceRandomRegistry
- Parameters:
name
- the name of the generator to create and registerseed
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- Parameters:
name
- the name of the distributiondist
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- Parameters:
ro
-pk
-- Returns:
- the created distribution
-
getZeta
public cern.jet.random.Zeta getZeta()
Gets the default Zeta distribution.- Specified by:
getZeta
in interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- 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 interfaceRandomRegistry
- Parameters:
alpha
-beta
-- Returns:
- the created distribution
-
getBeta
public cern.jet.random.Beta getBeta()
Gets the default beta distribution.- Specified by:
getBeta
in interfaceRandomRegistry
- Returns:
- the default beta distribution.
-
getBinomial
public cern.jet.random.Binomial getBinomial()
Gets the default binomial distribution.- Specified by:
getBinomial
in interfaceRandomRegistry
- Returns:
- the default binomial distribution.
-
getBreitWigner
public cern.jet.random.BreitWigner getBreitWigner()
Gets the default BreitWigner distribution.- Specified by:
getBreitWigner
in interfaceRandomRegistry
- Returns:
- the default BreitWigner distribution.
-
getBreitWignerMeanSquare
public cern.jet.random.BreitWignerMeanSquare getBreitWignerMeanSquare()
Gets the default BreitWignerMeanSquare distribution.- Specified by:
getBreitWignerMeanSquare
in interfaceRandomRegistry
- Returns:
- the default BreitWignerMeanSquare distribution.
-
getChiSquare
public cern.jet.random.ChiSquare getChiSquare()
Gets the default Zeta distribution.- Specified by:
getChiSquare
in interfaceRandomRegistry
- Returns:
- the default Zeta distribution.
-
getEmpirical
public cern.jet.random.Empirical getEmpirical()
Gets the default ChiSquare distribution.- Specified by:
getEmpirical
in interfaceRandomRegistry
- Returns:
- the default ChiSquare distribution.
-
getEmpiricalWalker
public cern.jet.random.EmpiricalWalker getEmpiricalWalker()
Gets the default EmpiricalWalker distribution.- Specified by:
getEmpiricalWalker
in interfaceRandomRegistry
- Returns:
- the default EmpiricalWalker distribution.
-
getExponential
public cern.jet.random.Exponential getExponential()
Gets the default Exponential distribution.- Specified by:
getExponential
in interfaceRandomRegistry
- Returns:
- the default Exponential distribution.
-
getExponentialPower
public cern.jet.random.ExponentialPower getExponentialPower()
Gets the default exponentialPower distribution.- Specified by:
getExponentialPower
in interfaceRandomRegistry
- Returns:
- the default exponentialPower distribution.
-
getGamma
public cern.jet.random.Gamma getGamma()
Gets the default gamma distribution.- Specified by:
getGamma
in interfaceRandomRegistry
- Returns:
- the default gamma distribution.
-
getHyperbolic
public cern.jet.random.Hyperbolic getHyperbolic()
Gets the default hyperbolic distribution.- Specified by:
getHyperbolic
in interfaceRandomRegistry
- Returns:
- the default hyperbolic distribution.
-
getHyperGeometric
public cern.jet.random.HyperGeometric getHyperGeometric()
Gets the default hyperGeometric distribution.- Specified by:
getHyperGeometric
in interfaceRandomRegistry
- Returns:
- the default hyperGeometric distribution.
-
getLogarithmic
public cern.jet.random.Logarithmic getLogarithmic()
Gets the default logarithmic distribution.- Specified by:
getLogarithmic
in interfaceRandomRegistry
- Returns:
- the default logarithmic distribution.
-
getNegativeBinomial
public cern.jet.random.NegativeBinomial getNegativeBinomial()
Gets the default negativeBinomial distribution.- Specified by:
getNegativeBinomial
in interfaceRandomRegistry
- Returns:
- the default negativeBinomial distribution.
-
getNormal
public cern.jet.random.Normal getNormal()
Gets the default normal distribution.- Specified by:
getNormal
in interfaceRandomRegistry
- Returns:
- the default normal distribution.
-
getPoisson
public cern.jet.random.Poisson getPoisson()
Gets the default poisson distribution.- Specified by:
getPoisson
in interfaceRandomRegistry
- Returns:
- the default poisson distribution.
-
getPoissonSlow
public cern.jet.random.PoissonSlow getPoissonSlow()
Gets the default slow poisson distribution.- Specified by:
getPoissonSlow
in interfaceRandomRegistry
- Returns:
- the default slow poisson distribution.
-
getStudentT
public cern.jet.random.StudentT getStudentT()
Gets the default studentT distribution.- Specified by:
getStudentT
in interfaceRandomRegistry
- Returns:
- the default studentT distribution.
-
getUniform
public cern.jet.random.Uniform getUniform()
Gets the default uniform distribution.- Specified by:
getUniform
in interfaceRandomRegistry
- Returns:
- the default uniform distribution.
-
getVonMises
public cern.jet.random.VonMises getVonMises()
Gets the default vonMises distribution.- Specified by:
getVonMises
in interfaceRandomRegistry
- 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 interfaceRandomRegistry
- Parameters:
seed
- the new seed
-
reset
public void reset()
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
- Specified by:
reset
in interfaceRandomRegistry
-
-