AgE 2.7 : Random generators

Concept

In order to abstract from the default java.util.Random, the random module introduces a few dedicated RandomGenerator interfaces. Those define a set of standard operations and specify contracts for their behavior.

Clients are then decoupled from the actual underlying probability distribution and random number generation algorithms. Different implementations can then be chosen at configuration or run time.

On this page:

Interfaces

The main interfaces in the module are IIntRandomGenerator and IDoubleRandomGenerator. They differ by returned value types, but specify a simple common contract: Implementations should define some bounded range in which the generated values will be included.
However, no assumptions are being made about the distribution of these values, which could be uniform or any other.

This contrasts with the java.util.Random class, which assumes both the range and the distribution of the values it generates.


An additional interface is IDoubleSymmetricGenerator, which further refine the IDoubleRandomGenerator one. It is intended for generators providing a distribution symmetrical around some central location and having some scaling factor.

It thus introduces an additional method, which takes two parameters for generated values: a location and a scale. The actual statistical interpretation of these parameters is left to implementations.
This interface also refines the general contract: The parameterless method for generating values should be semantically equal to the new one invoked with some default parameters.

Available implementations

SimpleGenerator

This class is simply a wrapper on the default java.util.Random, intended to map it against this module's API.

CauchyGenerator

This class generates values according to a Cauchy distribution. For that purpose, it decorates a given IDoubleRandomGenerator, which should be a uniform one (a SimpleGenerator will be the best).
The semantics of the location and scale parameters as such as in the Cauchy distribution.

GuassianGenerator

This class generates values according to a Guassian (Normal) distribution. For that purpose, it decorates a given IDoubleRandomGenerator, which should be a uniform one (a SimpleGenerator will be the best).
The location parameter represents the mean value, and the scale one is interpreted as the variance.

Summary

The following diagram illustrates the solution described here.

Attachments:

random.jpg (image/jpeg)