public final class RandomNumberChecks extends Object
Modifier and Type | Method and Description |
---|---|
<V extends IStochasticOccurrence> |
checkProbabilitySetting(String name,
Collection<V> objects,
List<GeneratorError> errors)
Tries to repeat values before throwing an exceptions.
|
<V extends IStochasticOccurrence> |
chooseNormalizedRandomObject(Collection<V> objects,
james.core.math.random.generators.IRandom rand)
Choose random object if the sum of all probabilities is 100.
|
<V extends IStochasticOccurrence> |
chooseRandomObject(Collection<V> objects,
james.core.math.random.generators.IRandom rand)
Choose random object if the sum of all probabilities is 100.
|
protected <V extends IStochasticOccurrence> |
chooseRandomObject(Collection<V> objects,
james.core.math.random.generators.IRandom rand,
double overallProbSum)
Choose random entity based on a certain probability sum.
|
static RandomNumberChecks |
getInstance()
Gets the single instance of RandomNumberChecks.
|
double |
getProbSum(Collection<? extends IStochasticOccurrence> objects)
Get the probability sum from a list of of
IStochasticOccurrence
instances. |
public static RandomNumberChecks getInstance()
public <V extends IStochasticOccurrence> void checkProbabilitySetting(String name, Collection<V> objects, List<GeneratorError> errors)
V
- type of entity that shall be chosen by chancename
- name of the objects to be checked (for generation of a suitable
error messages)objects
- the collection of objects to be checkederrors
- list of error messages (to be filled if something goes wrong)public <V extends IStochasticOccurrence> V chooseNormalizedRandomObject(Collection<V> objects, james.core.math.random.generators.IRandom rand)
V
- type of randomly chosen entityobjects
- collection of objects from which to chooserand
- randomiser to be usedpublic <V extends IStochasticOccurrence> V chooseRandomObject(Collection<V> objects, james.core.math.random.generators.IRandom rand)
V
- type of randomly chosen entityobjects
- collection of objects from which to chooserand
- the randomiser to be usedprotected <V extends IStochasticOccurrence> V chooseRandomObject(Collection<V> objects, james.core.math.random.generators.IRandom rand, double overallProbSum)
V
- type of randomly chosen entityobjects
- collection of objects from which to chooserand
- the randomiser to be usedoverallProbSum
- overall probability sumpublic double getProbSum(Collection<? extends IStochasticOccurrence> objects)
IStochasticOccurrence
instances.objects
- collection of objects from which to chooseCopyright © 2012. All Rights Reserved.