@PublicationReference(author="Wikipedia", title="Uniform distribution (continuous)", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)") public class UniformDistribution extends AbstractClosedFormSmoothUnivariateDistribution implements EstimableDistribution<java.lang.Double,UniformDistribution>
Modifier and Type | Class and Description |
---|---|
static class |
UniformDistribution.CDF
Cumulative Distribution Function of a uniform
|
static class |
UniformDistribution.MaximumLikelihoodEstimator
Maximum Likelihood Estimator of a uniform distribution.
|
static class |
UniformDistribution.PDF
Probability density function of a Uniform Distribution
|
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_MAX
Default max, 1.0.
|
static double |
DEFAULT_MIN
Default min, 0.0.
|
Constructor and Description |
---|
UniformDistribution()
Creates a new instance of UniformDistribution
|
UniformDistribution(double minSupport,
double maxSupport)
Creates a new instance of UniformDistribution
|
UniformDistribution(UniformDistribution other)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
UniformDistribution |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
void |
convertFromVector(Vector parameters)
Converts the object from a Vector of parameters.
|
Vector |
convertToVector()
Converts the object to a vector.
|
UniformDistribution.CDF |
getCDF()
Gets the CDF of a scalar distribution.
|
UniformDistribution.MaximumLikelihoodEstimator |
getEstimator()
Gets an estimator associated with this distribution.
|
java.lang.Double |
getMaxSupport()
Gets the minimum support (domain or input) of the distribution.
|
double |
getMeanAsDouble()
Gets the mean of the distribution as a double.
|
java.lang.Double |
getMinSupport()
Gets the minimum support (domain or input) of the distribution.
|
UniformDistribution.PDF |
getProbabilityFunction()
Gets the distribution function associated with this Distribution,
either the PDF or PMF.
|
double |
getVariance()
Gets the variance of the distribution.
|
java.lang.Double |
sample(java.util.Random random)
Draws a single random sample from the distribution.
|
void |
sampleInto(java.util.Random random,
double[] output,
int start,
int length)
Samples values from this distribution as an array of doubles.
|
void |
setMaxSupport(double maxSupport)
Setter for maxSupport
|
void |
setMinSupport(double minSupport)
Setter for minSupport
|
getMean, sampleAsDouble, sampleAsDoubles, sampleInto
sample
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sample, sampleInto
public static final double DEFAULT_MIN
public static final double DEFAULT_MAX
public UniformDistribution()
public UniformDistribution(double minSupport, double maxSupport)
minSupport
- Minimum x bound on the distributionmaxSupport
- Maximum bound on the distributionpublic UniformDistribution(UniformDistribution other)
other
- UniformDistribution to copypublic UniformDistribution clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface Vectorizable
clone
in interface CloneableSerializable
clone
in class AbstractClosedFormUnivariateDistribution<java.lang.Double>
public double getMeanAsDouble()
UnivariateDistribution
getMeanAsDouble
in interface UnivariateDistribution<java.lang.Double>
public double getVariance()
UnivariateDistribution
getVariance
in interface UnivariateDistribution<java.lang.Double>
public java.lang.Double sample(java.util.Random random)
Distribution
sample
in interface Distribution<java.lang.Double>
sample
in class AbstractDistribution<java.lang.Double>
random
- Random-number generator to use in order to generate random numbers.public void sampleInto(java.util.Random random, double[] output, int start, int length)
SmoothUnivariateDistribution
sampleInto
in interface SmoothUnivariateDistribution
random
- Random number generator to use.output
- The array to write the result into. Cannot be null.start
- The offset in the array to start writing at. Cannot be negative.length
- The number of values to sample. Cannot be negative.public java.lang.Double getMinSupport()
UnivariateDistribution
getMinSupport
in interface UnivariateDistribution<java.lang.Double>
public void setMinSupport(double minSupport)
minSupport
- Minimum x bound on the distributionpublic java.lang.Double getMaxSupport()
UnivariateDistribution
getMaxSupport
in interface UnivariateDistribution<java.lang.Double>
public void setMaxSupport(double maxSupport)
maxSupport
- Maximum x bound on the distributionpublic Vector convertToVector()
Vectorizable
convertToVector
in interface Vectorizable
public void convertFromVector(Vector parameters)
Vectorizable
convertFromVector
in interface Vectorizable
parameters
- The parameters to incorporate.public UniformDistribution.CDF getCDF()
UnivariateDistribution
getCDF
in interface ClosedFormUnivariateDistribution<java.lang.Double>
getCDF
in interface SmoothUnivariateDistribution
getCDF
in interface UnivariateDistribution<java.lang.Double>
public UniformDistribution.PDF getProbabilityFunction()
ComputableDistribution
getProbabilityFunction
in interface ComputableDistribution<java.lang.Double>
getProbabilityFunction
in interface SmoothUnivariateDistribution
public UniformDistribution.MaximumLikelihoodEstimator getEstimator()
EstimableDistribution
getEstimator
in interface EstimableDistribution<java.lang.Double,UniformDistribution>