de.cesr.lara.components.util.impl
Class LRandomService

java.lang.Object
  extended by de.cesr.lara.components.util.impl.LRandomService
All Implemented Interfaces:
LaraRandom

public class LRandomService
extends Object
implements LaraRandom

Uses the MersenneTwister as generator. TODO substitute by URaNuS (or clear generators) TODO document (SH) TODO methods to check if given distribution name is of given class


Field Summary
 
Fields inherited from interface de.cesr.lara.components.util.LaraRandom
NORMAL_DEFAULT, UNIFORM_DEFAULT
 
Constructor Summary
LRandomService(int seed)
          Initialise a new instance with the given random seed.
 
Method Summary
 Normal createNormal(double mean, double std)
          Create a normal distribution with the given parameters using the default random generator.
 Normal getCustomNormal(double mean, double std, String name)
           
 AbstractDistribution getDistribution(String name)
          Returns the AbstractDistribution that is registered for the given name.
 RandomEngine getGenerator(String name)
           
 Normal getNormal()
          Returns the Normal distribution that was created at last (therefore, mean and standard deviation is not defined).
 int getSeed()
          Get the seed currently used for the default distributions.
 Uniform getUniform()
          Return the default uniform distribution.
 boolean isDebugEnabled()
          Checks if the logger of LRandomService is set to debug.
 void registerDistribution(AbstractDistribution dist, String name)
          Registers a custom AbstractDistribution at the given name.
 void registerGenerator(String name, RandomEngine generator)
           
 void setSeed(int seed)
          Sets the seed for all random number generators.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LRandomService

public LRandomService(int seed)
Initialise a new instance with the given random seed.

Parameters:
seed -
Method Detail

createNormal

public Normal createNormal(double mean,
                           double std)
Description copied from interface: LaraRandom
Create a normal distribution with the given parameters using the default random generator.

Specified by:
createNormal in interface LaraRandom
Returns:
normal distribution with the given parameters
See Also:
LaraRandom.createNormal(double, double)

getCustomNormal

public Normal getCustomNormal(double mean,
                              double std,
                              String name)
Specified by:
getCustomNormal in interface LaraRandom
name - name of the generator to use from stored generators
Returns:
normal distribution
See Also:
LaraRandom.getCustomNormal(double, double, java.lang.String)

getDistribution

public AbstractDistribution getDistribution(String name)
Description copied from interface: LaraRandom
Returns the AbstractDistribution that is registered for the given name.

Specified by:
getDistribution in interface LaraRandom
Returns:
registered distribution
See Also:
LaraRandom.getDistribution(java.lang.String)

getGenerator

public RandomEngine getGenerator(String name)
Specified by:
getGenerator in interface LaraRandom
Returns:
random engine that is associated with the given String
See Also:
LaraRandom.getGenerator(java.lang.String)

getNormal

public Normal getNormal()
Description copied from interface: LaraRandom
Returns the Normal distribution that was created at last (therefore, mean and standard deviation is not defined). Equivalent to LaraRandom#getDistribution(LaraRandom.NORMAL_DEFAULT). Returns null if no normal distribution has been created yet.

Specified by:
getNormal in interface LaraRandom
Returns:
latest created normal distribution
See Also:
LaraRandom.getNormal()

getSeed

public int getSeed()
Description copied from interface: LaraRandom
Get the seed currently used for the default distributions.

Specified by:
getSeed in interface LaraRandom
Returns:
current seed
See Also:
LaraRandom.getSeed()

getUniform

public Uniform getUniform()
Description copied from interface: LaraRandom
Return the default uniform distribution. Equivalent to LaraRandom#getDistribution(LaraRandom.UNIFORM_DEFAULT).

Specified by:
getUniform in interface LaraRandom
Returns:
the default uniform distribution
See Also:
LaraRandom.getUniform()

isDebugEnabled

public boolean isDebugEnabled()
Description copied from interface: LaraRandom
Checks if the logger of LRandomService is set to debug.

Specified by:
isDebugEnabled in interface LaraRandom
Returns:
true if debug is enabled.
See Also:
LaraRandom.isDebugEnabled()

registerDistribution

public void registerDistribution(AbstractDistribution dist,
                                 String name)
Description copied from interface: LaraRandom
Registers a custom AbstractDistribution at the given name.

Specified by:
registerDistribution in interface LaraRandom
See Also:
de.cesr.lara.components.util.LaraRandom#registerDistribution(cern.jet.random.AbstractDistribution, java.lang.String)

registerGenerator

public void registerGenerator(String name,
                              RandomEngine generator)
Specified by:
registerGenerator in interface LaraRandom
Parameters:
name - to associte the given generator with
generator - to register
See Also:
de.cesr.lara.components.util.LaraRandom#registerGenerator(java.lang.String, cern.jet.random.engine.RandomEngine)

setSeed

public void setSeed(int seed)
Description copied from interface: LaraRandom
Sets the seed for all random number generators. If this method is called, a new random number generator is created, all registered distributions (also customly registered) are deleted and the default distributions are renewed.

Specified by:
setSeed in interface LaraRandom
See Also:
LaraRandom.setSeed(int)