public class NormalDistribution extends Object implements ProbabilityDistribution
dnorm, pnorm, qnorm, rnorm.
The second constructor argument is the standard deviation,
not the variance. Supply a finite, strictly positive value; this constructor
does not validate it. cdf(x) returns a probability, while
quantile(p) takes a probability and returns a value in the original
units. density(x) is a density, not the probability of an exact point.
kurtosis() returns excess kurtosis (zero for a normal distribution).
import dev.nm.stat.distribution.univariate.NormalDistribution;
NormalDistribution normal = new NormalDistribution(10.0, 2.0);
double probability = normal.cdf(10.0); // 0.5
assert Math.abs(probability - 0.5) < 1e-12;
assert Math.abs(normal.quantile(0.5) - 10.0) < 1e-12;
assert normal.variance() == 4.0;
Entropy is measured in nats. Multiplying the standard deviation by a positive factor adds the logarithm of that factor.
import dev.nm.stat.distribution.univariate.NormalDistribution;
NormalDistribution standard = new NormalDistribution();
NormalDistribution scaled = new NormalDistribution(20, 3);
assert Math.abs(standard.entropy() - 1.4189385332046727) < 1e-12;
assert Math.abs(scaled.entropy() - standard.entropy() - Math.log(3)) < 1e-12;
| Constructor and Description |
|---|
NormalDistribution()
Construct an instance of the standard Normal distribution with mean 0 and standard deviation 1.
|
NormalDistribution(double mu,
double sigma)
Construct a Normal distribution with mean
mu and standard deviation sigma. |
| Modifier and Type | Method and Description |
|---|---|
double |
cdf(double x)
Gets the cumulative probability F(x) = Pr(X ≤ x).
|
double |
density(double x)
The density function, which, if exists, is the derivative of F.
|
double |
entropy()
Returns differential entropy in nats (natural-logarithm units).
|
double |
kurtosis()
Gets the excess kurtosis of this distribution.
|
double |
mean()
Gets the mean of this distribution.
|
double |
median()
Gets the median of this distribution.
|
double |
moment(double t)
The moment generating function is the expected value of \(e^{tX}\).
|
double |
quantile(double u)
Gets the quantile, the inverse of the cumulative distribution function.
|
double |
skew()
Gets the skewness of this distribution.
|
double |
variance()
Gets the variance of this distribution.
|
public NormalDistribution()
public NormalDistribution(double mu,
double sigma)
mu and standard deviation sigma.mu - the meansigma - the standard deviation; the caller must supply a finite value greater than zeropublic double mean()
ProbabilityDistributionmean in interface ProbabilityDistributionpublic double median()
ProbabilityDistributionmedian in interface ProbabilityDistributionpublic double variance()
ProbabilityDistributionvariance in interface ProbabilityDistributionpublic double skew()
ProbabilityDistributionskew in interface ProbabilityDistributionpublic double kurtosis()
ProbabilityDistributionkurtosis in interface ProbabilityDistributionpublic double entropy()
entropy in interface ProbabilityDistributionpublic double cdf(double x)
ProbabilityDistributioncdf in interface ProbabilityDistributionx - xpublic double quantile(double u)
ProbabilityDistributionquantile in interface ProbabilityDistributionu - u, a quantilepublic double density(double x)
ProbabilityDistributiondensity in interface ProbabilityDistributionx - xpublic double moment(double t)
ProbabilityDistributionmoment in interface ProbabilityDistributiont - tCopyright © 2010-2026 NM Group. All Rights Reserved.