@PublicationReference(author="Wikipedia", title="Normal distribution", type=WebPage, year=2009, url="http://en.wikipedia.org/wiki/Normal_distribution") public class UnivariateGaussian extends AbstractClosedFormSmoothUnivariateDistribution implements EstimableDistribution<java.lang.Double,UnivariateGaussian>
| Modifier and Type | Class and Description |
|---|---|
static class |
UnivariateGaussian.CDF
CDF of the underlying Gaussian.
|
static class |
UnivariateGaussian.ErrorFunction
Gaussian Error Function, useful for computing the cumulative distribution
function for a Gaussian.
|
static class |
UnivariateGaussian.IncrementalEstimator
Implements an incremental estimator for the sufficient statistics for
a UnivariateGaussian.
|
static class |
UnivariateGaussian.MaximumLikelihoodEstimator
Creates a UnivariateGaussian from data
|
static class |
UnivariateGaussian.PDF
PDF of the underlying Gaussian.
|
static class |
UnivariateGaussian.SufficientStatistic
Captures the sufficient statistics of a UnivariateGaussian, which are
the values to estimate the mean and variance.
|
static class |
UnivariateGaussian.WeightedMaximumLikelihoodEstimator
Creates a UnivariateGaussian from weighted data
|
| Modifier and Type | Field and Description |
|---|---|
static double |
BIG_Z
A big value to input into the Gaussian CDF that will get 1.0
probability, 100.0.
|
static double |
DEFAULT_MEAN
Default mean, 0.0.
|
static double |
DEFAULT_VARIANCE
Default variance, 1.0.
|
protected double |
mean
First central moment (expectation) of the distribution
|
static double |
PI2
PI times 2.0, 6.283185307179586
|
static double |
SQRT2
Square root of 2.0, 0.707...
|
protected double |
variance
Second central moment (square of standard deviation) of the distribution
|
| Constructor and Description |
|---|
UnivariateGaussian()
Creates a new instance of UnivariateGaussian
with zero mean and unit variance
|
UnivariateGaussian(double mean,
double variance)
Creates a new instance of UnivariateGaussian
|
UnivariateGaussian(UnivariateGaussian other)
Copy constructor
|
| Modifier and Type | Method and Description |
|---|---|
UnivariateGaussian |
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.
|
UnivariateGaussian |
convolve(UnivariateGaussian other)
Convolves this Gaussian with the other Gaussian.
|
UnivariateGaussian.CDF |
getCDF()
Gets the CDF of a scalar distribution.
|
UnivariateGaussian.MaximumLikelihoodEstimator |
getEstimator()
Gets an estimator associated with this distribution.
|
java.lang.Double |
getMaxSupport()
Gets the minimum support (domain or input) of the distribution.
|
java.lang.Double |
getMean()
Getter for mean
|
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.
|
UnivariateGaussian.PDF |
getProbabilityFunction()
Gets the distribution function associated with this Distribution,
either the PDF or PMF.
|
double |
getStandardDeviation()
Gets the standard deviation, which is the square root of the variance.
|
double |
getVariance()
Gets the variance of the distribution.
|
double |
sampleAsDouble(java.util.Random random)
Samples a value from this distribution as a double.
|
void |
sampleInto(java.util.Random random,
double[] output,
int start,
int length)
Samples values from this distribution as an array of doubles.
|
void |
setMean(double mean)
Setter for mean
|
void |
setVariance(double variance)
Setter for variance
|
UnivariateGaussian |
times(UnivariateGaussian other)
Multiplies this Gaussian with the other Gaussian.
|
java.lang.String |
toString()
Returns the string representation of the object.
|
sampleAsDoubles, sampleIntosample, sampleequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitsample, sample, sampleIntopublic static final double DEFAULT_MEAN
public static final double DEFAULT_VARIANCE
protected double mean
protected double variance
public static final double BIG_Z
public static final double SQRT2
public static final double PI2
public UnivariateGaussian()
public UnivariateGaussian(double mean,
double variance)
mean - First central moment (expectation) of the distributionvariance - Second central moment (square of standard deviation) of the distributionpublic UnivariateGaussian(UnivariateGaussian other)
other - UnivariateGaussian to copypublic UnivariateGaussian clone()
AbstractCloneableSerializableObject 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 Vectorizableclone in interface CloneableSerializableclone in class AbstractClosedFormUnivariateDistribution<java.lang.Double>public java.lang.Double getMean()
getMean in interface DistributionWithMean<java.lang.Double>getMean in interface SmoothUnivariateDistributiongetMean in class AbstractClosedFormSmoothUnivariateDistributionpublic void setMean(double mean)
mean - First central moment (expectation) of the distributionpublic double getMeanAsDouble()
UnivariateDistributiongetMeanAsDouble in interface UnivariateDistribution<java.lang.Double>public double getVariance()
UnivariateDistributiongetVariance in interface UnivariateDistribution<java.lang.Double>public void setVariance(double variance)
variance - Second central moment (square of standard deviation) of the distributionpublic double getStandardDeviation()
public java.lang.String toString()
toString in class java.lang.Objectpublic double sampleAsDouble(java.util.Random random)
SmoothUnivariateDistributionsampleAsDouble in interface SmoothUnivariateDistributionsampleAsDouble in class AbstractClosedFormSmoothUnivariateDistributionrandom - Random number generator to use.public void sampleInto(java.util.Random random,
double[] output,
int start,
int length)
SmoothUnivariateDistributionsampleInto in interface SmoothUnivariateDistributionrandom - 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 Vector convertToVector()
VectorizableconvertToVector in interface Vectorizablepublic void convertFromVector(Vector parameters)
VectorizableconvertFromVector in interface Vectorizableparameters - The parameters to incorporate.public UnivariateGaussian.CDF getCDF()
UnivariateDistributiongetCDF in interface ClosedFormUnivariateDistribution<java.lang.Double>getCDF in interface SmoothUnivariateDistributiongetCDF in interface UnivariateDistribution<java.lang.Double>public UnivariateGaussian.PDF getProbabilityFunction()
ComputableDistributiongetProbabilityFunction in interface ComputableDistribution<java.lang.Double>getProbabilityFunction in interface SmoothUnivariateDistributionpublic java.lang.Double getMinSupport()
UnivariateDistributiongetMinSupport in interface UnivariateDistribution<java.lang.Double>public java.lang.Double getMaxSupport()
UnivariateDistributiongetMaxSupport in interface UnivariateDistribution<java.lang.Double>public UnivariateGaussian times(UnivariateGaussian other)
other - Other Gaussian to multiply with this.public UnivariateGaussian convolve(UnivariateGaussian other)
other - Other Gaussian to convolve with this.public UnivariateGaussian.MaximumLikelihoodEstimator getEstimator()
EstimableDistributiongetEstimator in interface EstimableDistribution<java.lang.Double,UnivariateGaussian>