UniformDistr

public class UniformDistr extends ContinuousDistributionAbstract

A pseudo random number generator following the Uniform continuous distribution.

Author:Marcos Dias de Assuncao

Constructors

UniformDistr

public UniformDistr()

Creates new uniform pseudo random number generator that generates values between [0 and 1[ using the current time as seed.

UniformDistr

public UniformDistr(long seed)

Creates new uniform pseudo random number generator that generates values between [0 and 1[ using a given seed.

Parameters:
  • seed – simulation seed to be used

UniformDistr

public UniformDistr(double max)

Creates new uniform pseudo random number generator that produces values between a 0 (inclusive) and max (exclusive).

Parameters:
  • max – maximum value (exclusive)

UniformDistr

public UniformDistr(double min, double max)

Creates new uniform pseudo random number generator that produces values between a min (inclusive) and max (exclusive).

Parameters:
  • min – minimum value (inclusive)
  • max – maximum value (exclusive)

UniformDistr

public UniformDistr(double min, double max, long seed)

Creates new uniform pseudo random number generator.

Parameters:
  • min – minimum value (inclusive)
  • max – maximum value (exclusive)
  • seed – simulation seed to be used

Methods

isApplyAntitheticVariates

public boolean isApplyAntitheticVariates()

Indicates if the pseudo random number generator (PRNG) has to apply the Antithetic Variates Technique in order to reduce variance of experiments using this PRNG. This technique doesn’t work for all the cases. However, in the cases it can be applied, in order to it work, one have to perform some actions. Consider an experiment that has to run “n” times. The first half of these experiments has to use the seeds the developer want. However, the second half of the experiments have to set the applyAntitheticVariates attribute to true and use the seeds of the first half of experiments. Thus, the first half of experiments are run using PRNGs that return random numbers as U(0, 1)[seed_1], …, U(0, 1)[seed_n]. The second half of experiments then uses the seeds of the first half of experiments, returning random numbers as 1 - U(0, 1)[seed_1], …, 1 - U(0, 1)[seed_n].

Returns:true if the technique has to be applied, false otherwise

sample

public double sample()

sample

public static double sample(Random rd, double min, double max)

Generates a new pseudo random number based on the generator and values provided as parameters.

Parameters:
  • rd – the random number generator
  • min – the minimum value
  • max – the maximum value
Returns:

the next random number in the sequence

setApplyAntitheticVariates

public UniformDistr setApplyAntitheticVariates(boolean applyAntitheticVariates)

Defines if the pseudo random number generator (PRNG) has to apply the Antithetic Variates Technique in order to reduce variance of experiments using this PRNG.

Parameters:
  • applyAntitheticVariates – true if the technique has to be applied, false otherwise

See also: .isApplyAntitheticVariates()