Class Uniform
java.lang.Object
random.AbstractDistribution
random.Uniform
- All Implemented Interfaces:
Distribution, StorableDistribution
This is the Uniform distribution.This object offers many
methods to obtain random value distributed like a uniform. This is because
the Uniform distribution must be also used by external classes as an
interface with the real pseudo-random number generator (which return many
type of value distributed like a uniform too). (see the constructor
description for its pdf definition).
Copyright (c) 2003
Politecnico di Milano - dipartimento di Elettronica e Informazione
Copyright (c) 2003
Politecnico di Milano - dipartimento di Elettronica e Informazione
- Author:
- Fabrizio Frontera - ffrontera@yahoo.it, Modified by Stefano Omini, 7/5/2004
-
Field Summary
Fields inherited from class AbstractDistribution
engine -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleThis method is used to obtain from the distribution its cumulative distribution function evaluated where required by the user.booleanThis method is used to obtain from the distribution the next boolean distributed according to the distribution parameter.intThis method is used to obtain from the distribution the next integer number distributed according to the distribution parameter.doubleThis method is used to obtain from the distribution the next Long integer number distributed according to the distribution parameter.doubleThis method is used to obtain from the distribution the next number distributed according to the distribution parameter.doubleThis method is used to obtain from the distribution its probability distribution function evaluated where required by the user.doubleThis method is used to obtain from the distribution the value of its own theoretic mean.doubleThis method is used to obtain from the distribution the value of its own theoretic variance.Methods inherited from class AbstractDistribution
setRandomEngineMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Distribution
setRandomEngine
-
Constructor Details
-
Uniform
public Uniform()This is the constructor. It creates a new uniform distribution which is defined from pdf:1 pdf(x) = ----------- max-minwhere max and min are two double boundaries for the distribution. max must be greater than min. If x is not between min and max, pdf(x)=0.
-
-
Method Details
-
pdf
This method is used to obtain from the distribution its probability distribution function evaluated where required by the user.- Specified by:
pdfin interfaceDistribution- Parameters:
x- double indicating where to evaluate the pdf.p- parameter of the uniform distribution.- Returns:
- double with the probability distribution function evaluated in x.
- Throws:
IncorrectDistributionParameterException
-
cdf
This method is used to obtain from the distribution its cumulative distribution function evaluated where required by the user.- Specified by:
cdfin interfaceDistribution- Parameters:
x- double indicating where to evaluate the cdf.p- parameter of the uniform distribution.- Returns:
- double with the cumulative distribution function evaluated in x.
- Throws:
IncorrectDistributionParameterException
-
theorMean
This method is used to obtain from the distribution the value of its own theoretic mean. For the uniform distribution, the theoretic mean is calculated as (max+min)/2.- Specified by:
theorMeanin interfaceDistribution- Parameters:
p- parameter of the uniform distribution.- Returns:
- double with the theoretic mean of the distribution.
- Throws:
IncorrectDistributionParameterException
-
theorVariance
This method is used to obtain from the distribution the value of its own theoretic variance. For the uniform distribution, the theoretic variance is calculated as ((max-min)^2)/12.- Specified by:
theorVariancein interfaceDistribution- Parameters:
p- parameter of the uniform distribution.- Returns:
- double with the theoretic variance of the distribution.
- Throws:
IncorrectDistributionParameterException
-
nextLong
This method is used to obtain from the distribution the next Long integer number distributed according to the distribution parameter.- Parameters:
p- parameter of the uniform distribution.- Returns:
- double with the next random number of this distribution.
- Throws:
IncorrectDistributionParameterException
-
nextBoolean
public boolean nextBoolean()This method is used to obtain from the distribution the next boolean distributed according to the distribution parameter.- Returns:
- boolean with the next random boolean of this distribution.
-
nextInt
This method is used to obtain from the distribution the next integer number distributed according to the distribution parameter.- Parameters:
p- parameter of the uniform distribution.- Returns:
- int with the next random number of this distribution.
- Throws:
IncorrectDistributionParameterException
-
nextRand
This method is used to obtain from the distribution the next number distributed according to the distribution parameter.- Specified by:
nextRandin interfaceDistribution- Parameters:
p- parameter of the uniform distribution.- Returns:
- double with the next random number of this distribution.
- Throws:
IncorrectDistributionParameterException
-