Class NormalDistribution
- java.lang.Object
-
- elki.math.statistics.distribution.NormalDistribution
-
- All Implemented Interfaces:
Distribution
@Alias({"GaussianDistribution","normal","gauss"}) public class NormalDistribution extends java.lang.Object implements Distribution
Gaussian distribution aka normal distribution- Since:
- 0.5.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNormalDistribution.ParParameterization class-
Nested classes/interfaces inherited from interface elki.math.statistics.distribution.Distribution
Distribution.Parameterizer
-
-
Field Summary
Fields Modifier and Type Field Description private static double[]ERF_COEFF1T.private static double[]ERF_COEFF2T.private doublemeanMean value for the generatorstatic doubleONEBYPHIINV0751 / CDFINV(0.75)(package private) static doubleP_HIGHTreshold for switching nethods for erfinv approximation(package private) static doubleP_LOWTreshold for switching nethods for erfinv approximationstatic doublePHIINV075CDFINV(0.75)private doublestddevStandard deviation
-
Constructor Summary
Constructors Constructor Description NormalDistribution(double mean, double stddev)Constructor for Gaussian distribution
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecdf(double val)Return the cumulative density function at the given value.static doublecdf(double x, double mu, double sigma)Cumulative probability density function (CDF) of a normal distribution.static doubleerf(double x)Error function for Gaussian distributions = Normal distributions.static doubleerfc(double x)Complementary error function for Gaussian distributions = Normal distributions.static doubleerfcinv(double y)Inverse error function.doublegetMean()doublegetStddev()doublelogpdf(double val)Return the log density of an existing valuestatic doublelogpdf(double x, double mu, double sigma)Log probability density function of the normal distribution.doublenextRandom(java.util.Random random)Generate a new random valuedoublepdf(double val)Return the density of an existing valuestatic doublepdf(double x, double mu, double sigma)Probability density function of the normal distribution.doublequantile(double q)Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.static doublequantile(double x, double mu, double sigma)Inverse cumulative probability density function (probit) of a normal distribution.static doublestandardNormalCDF(double x)Cumulative probability density function (CDF) of a normal distribution.static doublestandardNormalLogPDF(double x)Log probability density function of the standard normal distribution.static doublestandardNormalPDF(double x)Probability density function of the standard normal distribution.static doublestandardNormalQuantile(double d)Approximate the inverse error function for normal distributions.java.lang.StringtoString()Describe the distribution
-
-
-
Field Detail
-
P_LOW
static final double P_LOW
Treshold for switching nethods for erfinv approximation- See Also:
- Constant Field Values
-
P_HIGH
static final double P_HIGH
Treshold for switching nethods for erfinv approximation- See Also:
- Constant Field Values
-
PHIINV075
public static final double PHIINV075
CDFINV(0.75)- See Also:
- Constant Field Values
-
ONEBYPHIINV075
public static final double ONEBYPHIINV075
1 / CDFINV(0.75)- See Also:
- Constant Field Values
-
mean
private double mean
Mean value for the generator
-
stddev
private double stddev
Standard deviation
-
ERF_COEFF1
private static final double[] ERF_COEFF1
T. Ooura, http://www.kurims.kyoto-u.ac.jp/~ooura/gamerf.html
-
ERF_COEFF2
private static final double[] ERF_COEFF2
T. Ooura, http://www.kurims.kyoto-u.ac.jp/~ooura/gamerf.html
-
-
Method Detail
-
pdf
public double pdf(double val)
Description copied from interface:DistributionReturn the density of an existing value- Specified by:
pdfin interfaceDistribution- Parameters:
val- existing value- Returns:
- distribution density
-
logpdf
public double logpdf(double val)
Description copied from interface:DistributionReturn the log density of an existing value- Specified by:
logpdfin interfaceDistribution- Parameters:
val- existing value- Returns:
- log distribution density
-
cdf
public double cdf(double val)
Description copied from interface:DistributionReturn the cumulative density function at the given value.- Specified by:
cdfin interfaceDistribution- Parameters:
val- existing value- Returns:
- cumulative density
-
quantile
public double quantile(double q)
Description copied from interface:DistributionQuantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.- Specified by:
quantilein interfaceDistribution- Parameters:
q- Quantile to find- Returns:
- Quantile position
-
nextRandom
public double nextRandom(java.util.Random random)
Description copied from interface:DistributionGenerate a new random value- Specified by:
nextRandomin interfaceDistribution- Parameters:
random- Random number generator- Returns:
- new random value
-
toString
public java.lang.String toString()
Description copied from interface:DistributionDescribe the distribution- Specified by:
toStringin interfaceDistribution- Overrides:
toStringin classjava.lang.Object- Returns:
- description
-
getMean
public double getMean()
- Returns:
- the mean
-
getStddev
public double getStddev()
- Returns:
- the standard deviation
-
erfc
@Reference(authors="T. Ooura", title="Gamma / Error Functions", booktitle="", url="http://www.kurims.kyoto-u.ac.jp/~ooura/gamerf.html", bibkey="web/Ooura96") public static double erfc(double x)
Complementary error function for Gaussian distributions = Normal distributions.Based on:
Takuya Ooura, http://www.kurims.kyoto-u.ac.jp/~ooura/gamerf.html
Copyright (C) 1996 Takuya OOURA (email: ooura@mmm.t.u-tokyo.ac.jp).
"You may use, copy, modify this code for any purpose and without fee."- Parameters:
x- parameter value- Returns:
- erfc(x)
-
erf
public static double erf(double x)
Error function for Gaussian distributions = Normal distributions.- Parameters:
x- parameter value- Returns:
- erf(x)
-
erfcinv
@Reference(authors="T. Ooura", title="Gamma / Error Functions", booktitle="", url="http://www.kurims.kyoto-u.ac.jp/~ooura/gamerf.html", bibkey="web/Ooura96") public static double erfcinv(double y)
Inverse error function.Based on:
T. Ooura, http://www.kurims.kyoto-u.ac.jp/~ooura/gamerf.html
Copyright (C) 1996 Takuya OOURA (email: ooura@mmm.t.u-tokyo.ac.jp).
"You may use, copy, modify this code for any purpose and without fee."- Parameters:
y- parameter value- Returns:
- erfcinv(y)
-
pdf
public static double pdf(double x, double mu, double sigma)Probability density function of the normal distribution.\[ \frac{1}{\sqrt{2\pi\sigma^2}} \exp(-\frac{(x-\mu)^2}{2\sigma^2}) \]
- Parameters:
x- The value.mu- The mean.sigma- The standard deviation.- Returns:
- PDF of the given normal distribution at x.
-
logpdf
public static double logpdf(double x, double mu, double sigma)Log probability density function of the normal distribution.\[\log\frac{1}{\sqrt{2\pi}} - \log\sigma - \tfrac{(x-\mu)^2}{2\sigma^2}\]
- Parameters:
x- The value.mu- The mean.sigma- The standard deviation.- Returns:
- PDF of the given normal distribution at x.
-
standardNormalLogPDF
public static double standardNormalLogPDF(double x)
Log probability density function of the standard normal distribution.\[ \log\frac{1}{\sqrt{2\pi}} -\frac{x^2}{2}) \]
- Parameters:
x- The value.- Returns:
- PDF of the given normal distribution at x.
-
standardNormalPDF
public static double standardNormalPDF(double x)
Probability density function of the standard normal distribution.\[ \frac{1}{\sqrt{2\pi}} \exp(-\frac{x^2}{2}) \]
- Parameters:
x- The value.- Returns:
- PDF of the given normal distribution at x.
-
cdf
@Reference(authors="G. Marsaglia", title="Evaluating the Normal Distribution", booktitle="Journal of Statistical Software 11(4)", url="https://doi.org/10.18637/jss.v011.i04", bibkey="doi:10.18637/jss.v011.i04") public static double cdf(double x, double mu, double sigma)
Cumulative probability density function (CDF) of a normal distribution.Reference:
G. Marsaglia
Evaluating the Normal Distribution
Journal of Statistical Software 11(4)- Parameters:
x- value to evaluate CDF atmu- Mean valuesigma- Standard deviation.- Returns:
- The CDF of the given normal distribution at x.
-
standardNormalCDF
@Reference(authors="G. Marsaglia", title="Evaluating the Normal Distribution", booktitle="Journal of Statistical Software 11(4)", url="https://doi.org/10.18637/jss.v011.i04", bibkey="doi:10.18637/jss.v011.i04") public static double standardNormalCDF(double x)
Cumulative probability density function (CDF) of a normal distribution.Reference:
G. Marsaglia
Evaluating the Normal Distribution
Journal of Statistical Software 11(4)- Parameters:
x- value to evaluate CDF at- Returns:
- The CDF of the given normal distribution at x.
-
quantile
public static double quantile(double x, double mu, double sigma)Inverse cumulative probability density function (probit) of a normal distribution.- Parameters:
x- value to evaluate probit function atmu- Mean valuesigma- Standard deviation.- Returns:
- The probit of the given normal distribution at x.
-
standardNormalQuantile
public static double standardNormalQuantile(double d)
Approximate the inverse error function for normal distributions.- Parameters:
d- Quantile. Must be in [0:1], obviously.- Returns:
- Inverse erf.
-
-