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 class
NormalDistribution.Par
Parameterization 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_COEFF1
T.private static double[]
ERF_COEFF2
T.private double
mean
Mean value for the generatorstatic double
ONEBYPHIINV075
1 / CDFINV(0.75)(package private) static double
P_HIGH
Treshold for switching nethods for erfinv approximation(package private) static double
P_LOW
Treshold for switching nethods for erfinv approximationstatic double
PHIINV075
CDFINV(0.75)private double
stddev
Standard 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 double
cdf(double val)
Return the cumulative density function at the given value.static double
cdf(double x, double mu, double sigma)
Cumulative probability density function (CDF) of a normal distribution.static double
erf(double x)
Error function for Gaussian distributions = Normal distributions.static double
erfc(double x)
Complementary error function for Gaussian distributions = Normal distributions.static double
erfcinv(double y)
Inverse error function.double
getMean()
double
getStddev()
double
logpdf(double val)
Return the log density of an existing valuestatic double
logpdf(double x, double mu, double sigma)
Log probability density function of the normal distribution.double
nextRandom(java.util.Random random)
Generate a new random valuedouble
pdf(double val)
Return the density of an existing valuestatic double
pdf(double x, double mu, double sigma)
Probability density function of the normal distribution.double
quantile(double q)
Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.static double
quantile(double x, double mu, double sigma)
Inverse cumulative probability density function (probit) of a normal distribution.static double
standardNormalCDF(double x)
Cumulative probability density function (CDF) of a normal distribution.static double
standardNormalLogPDF(double x)
Log probability density function of the standard normal distribution.static double
standardNormalPDF(double x)
Probability density function of the standard normal distribution.static double
standardNormalQuantile(double d)
Approximate the inverse error function for normal distributions.java.lang.String
toString()
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:Distribution
Return the density of an existing value- Specified by:
pdf
in interfaceDistribution
- Parameters:
val
- existing value- Returns:
- distribution density
-
logpdf
public double logpdf(double val)
Description copied from interface:Distribution
Return the log density of an existing value- Specified by:
logpdf
in interfaceDistribution
- Parameters:
val
- existing value- Returns:
- log distribution density
-
cdf
public double cdf(double val)
Description copied from interface:Distribution
Return the cumulative density function at the given value.- Specified by:
cdf
in interfaceDistribution
- Parameters:
val
- existing value- Returns:
- cumulative density
-
quantile
public double quantile(double q)
Description copied from interface:Distribution
Quantile aka probit (for normal) aka inverse CDF (invcdf, cdf^-1) function.- Specified by:
quantile
in interfaceDistribution
- Parameters:
q
- Quantile to find- Returns:
- Quantile position
-
nextRandom
public double nextRandom(java.util.Random random)
Description copied from interface:Distribution
Generate a new random value- Specified by:
nextRandom
in interfaceDistribution
- Parameters:
random
- Random number generator- Returns:
- new random value
-
toString
public java.lang.String toString()
Description copied from interface:Distribution
Describe the distribution- Specified by:
toString
in interfaceDistribution
- Overrides:
toString
in 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.
-
-