Package cern.jet.random
Class Uniform
-
- All Implemented Interfaces:
DoubleFunction
,IntFunction
,Serializable
,Cloneable
public class Uniform extends AbstractContinousDistribution
Uniform distribution; Math definition and animated definition.Instance methods operate on a user supplied uniform random number generator; they are unsynchronized.
- Static methods operate on a default uniform random number generator; they are synchronized.
- Version:
- 1.0, 09/24/99
- Author:
- wolfgang.hoschek@cern.ch
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected double
max
protected double
min
protected static Uniform
shared
-
Fields inherited from class cern.jet.random.AbstractDistribution
randomGenerator
-
-
Constructor Summary
Constructors Constructor Description Uniform(double min, double max, int seed)
Constructs a uniform distribution with the given minimum and maximum, using aMersenneTwister
seeded with the given seed.Uniform(double min, double max, RandomEngine randomGenerator)
Constructs a uniform distribution with the given minimum and maximum.Uniform(RandomEngine randomGenerator)
Constructs a uniform distribution withmin=0.0
andmax=1.0
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
cdf(double x)
Returns the cumulative distribution function (assuming a continous uniform distribution).boolean
nextBoolean()
Returns a uniformly distributed randomboolean
.double
nextDouble()
Returns a uniformly distributed random number in the open interval(min,max)
(excludingmin
andmax
).double
nextDoubleFromTo(double from, double to)
Returns a uniformly distributed random number in the open interval(from,to)
(excludingfrom
andto
).float
nextFloatFromTo(float from, float to)
Returns a uniformly distributed random number in the open interval(from,to)
(excludingfrom
andto
).int
nextInt()
Returns a uniformly distributed random number in the closed interval[min,max]
(includingmin
andmax
).int
nextIntFromTo(int from, int to)
Returns a uniformly distributed random number in the closed interval[from,to]
(includingfrom
andto
).long
nextLongFromTo(long from, long to)
Returns a uniformly distributed random number in the closed interval[from,to]
(includingfrom
andto
).double
pdf(double x)
Returns the probability distribution function (assuming a continous uniform distribution).void
setState(double min, double max)
Sets the internal state.static boolean
staticNextBoolean()
Returns a uniformly distributed randomboolean
.static double
staticNextDouble()
Returns a uniformly distributed random number in the open interval(0,1)
(excluding0
and1
).static double
staticNextDoubleFromTo(double from, double to)
Returns a uniformly distributed random number in the open interval(from,to)
(excludingfrom
andto
).static float
staticNextFloatFromTo(float from, float to)
Returns a uniformly distributed random number in the open interval(from,to)
(excludingfrom
andto
).static int
staticNextIntFromTo(int from, int to)
Returns a uniformly distributed random number in the closed interval[from,to]
(includingfrom
andto
).static long
staticNextLongFromTo(long from, long to)
Returns a uniformly distributed random number in the closed interval[from,to]
(includingfrom
andto
).static void
staticSetRandomEngine(RandomEngine randomGenerator)
Sets the uniform random number generation engine shared by all static methods.String
toString()
Returns a String representation of the receiver.-
Methods inherited from class cern.jet.random.AbstractDistribution
apply, apply, clone, getRandomGenerator, makeDefaultGenerator, setRandomGenerator
-
-
-
-
Field Detail
-
min
protected double min
-
max
protected double max
-
shared
protected static Uniform shared
-
-
Constructor Detail
-
Uniform
public Uniform(double min, double max, int seed)
Constructs a uniform distribution with the given minimum and maximum, using aMersenneTwister
seeded with the given seed.
-
Uniform
public Uniform(double min, double max, RandomEngine randomGenerator)
Constructs a uniform distribution with the given minimum and maximum.
-
Uniform
public Uniform(RandomEngine randomGenerator)
Constructs a uniform distribution withmin=0.0
andmax=1.0
.
-
-
Method Detail
-
cdf
public double cdf(double x)
Returns the cumulative distribution function (assuming a continous uniform distribution).
-
nextBoolean
public boolean nextBoolean()
Returns a uniformly distributed randomboolean
.
-
nextDouble
public double nextDouble()
Returns a uniformly distributed random number in the open interval(min,max)
(excludingmin
andmax
).- Specified by:
nextDouble
in classAbstractDistribution
-
nextDoubleFromTo
public double nextDoubleFromTo(double from, double to)
Returns a uniformly distributed random number in the open interval(from,to)
(excludingfrom
andto
). Pre conditions:from <= to
.
-
nextFloatFromTo
public float nextFloatFromTo(float from, float to)
Returns a uniformly distributed random number in the open interval(from,to)
(excludingfrom
andto
). Pre conditions:from <= to
.
-
nextInt
public int nextInt()
Returns a uniformly distributed random number in the closed interval[min,max]
(includingmin
andmax
).- Overrides:
nextInt
in classAbstractDistribution
-
nextIntFromTo
public int nextIntFromTo(int from, int to)
Returns a uniformly distributed random number in the closed interval[from,to]
(includingfrom
andto
). Pre conditions:from <= to
.
-
nextLongFromTo
public long nextLongFromTo(long from, long to)
Returns a uniformly distributed random number in the closed interval[from,to]
(includingfrom
andto
). Pre conditions:from <= to
.
-
pdf
public double pdf(double x)
Returns the probability distribution function (assuming a continous uniform distribution).
-
setState
public void setState(double min, double max)
Sets the internal state.
-
staticNextBoolean
public static boolean staticNextBoolean()
Returns a uniformly distributed randomboolean
.
-
staticNextDouble
public static double staticNextDouble()
Returns a uniformly distributed random number in the open interval(0,1)
(excluding0
and1
).
-
staticNextDoubleFromTo
public static double staticNextDoubleFromTo(double from, double to)
Returns a uniformly distributed random number in the open interval(from,to)
(excludingfrom
andto
). Pre conditions:from <= to
.
-
staticNextFloatFromTo
public static float staticNextFloatFromTo(float from, float to)
Returns a uniformly distributed random number in the open interval(from,to)
(excludingfrom
andto
). Pre conditions:from <= to
.
-
staticNextIntFromTo
public static int staticNextIntFromTo(int from, int to)
Returns a uniformly distributed random number in the closed interval[from,to]
(includingfrom
andto
). Pre conditions:from <= to
.
-
staticNextLongFromTo
public static long staticNextLongFromTo(long from, long to)
Returns a uniformly distributed random number in the closed interval[from,to]
(includingfrom
andto
). Pre conditions:from <= to
.
-
staticSetRandomEngine
public static void staticSetRandomEngine(RandomEngine randomGenerator)
Sets the uniform random number generation engine shared by all static methods.- Parameters:
randomGenerator
- the new uniform random number generation engine to be shared.
-
-