Class Distributions
- Author:
- Christoph Hauert
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Ensure non-instantiability with private default constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic double
bimodality
(double[] x) Bimodality coefficient of data pointsx[i]
stored in double vectorx
.static double
bimodality
(double[] x, double m1) Bimodality coefficient of data pointsx[i]
stored in double vectorx
with known meanm1
.static double
centralMoment
(double[] x, double m1, int m) m
-th centralized moment of data pointsx[i]
stored in double vectorx
with known meanm1
.static double
centralMoment
(double[] x, int m) m
-th centralized moment of data pointsx[i]
stored in double vectorx
.static double
correlation
(double[] x, double[] y) Pearson correlation coefficient between data pointsx[i]
,y[i]
stored in double vectorsx
andy
using one-pass algorithm based on Welford's algorithm.static double
correlation
(double[] x, double meanx, double varx, double[] y, double meany, double vary) Pearson correlation coefficient between data pointsx[i]
,y[i]
stored in double vectorsx
andy
with known meansmeanx
,meany
and variancesvarx
,vary
.static double
covariance
(double[] x, double[] y) Sample covariance of data pointsx[i]
,y[i]
stored in double vectorsx
andy
using one-pass algorithm based on Welford's algorithm.static double
covariance
(double[] x, double meanx, double[] y, double meany) Sample covariance of data pointsx[i]
,y[i]
stored in double vectorsx
andy
with known meansmeanx
andmeany
.static double
distrCentralMoment
(double[] w, int m) m
-th central moment of probability distribution with weightsw[i]
stored in double vectorw
.static double
distrCentralMoment
(double[] w, int m, double m1) m
-th central moment of probability distribution with weightsw[i]
stored in double vectorw
with known meanm1
.static double
distrMean
(double[] w) Mean of probability distribution with weightsw[i]
stored in double vectorw
.static double
distrMoment
(double[] w, int m) m
-th moment of probability distribution with weightsw[i]
stored in double vectorw
.static double
distrStdev
(double[] w) Standard deviation of probability distribution with weightsw[i]
stored in double vectorw
.static double
distrStdev
(double[] w, double m1) Standard deviation of probability distribution with weightsw[i]
stored in double vectorw
with known meanm1
.static double
distrVariance
(double[] w) Variance of probability distribution with weightsw[i]
stored in double vectorw
.static double
distrVariance
(double[] w, double m1) Variance of probability distribution with weightsw[i]
stored in double vectorw
with known meanm1
.static double
kurtosis
(double[] x) Sample kurtosis of data pointsx[i]
stored in double vectorx
.static double
kurtosis
(double[] x, double m1) Sample kurtosis of data pointsx[i]
stored in double vectorx
with known meanm1
.static double
mean
(double[] x) Mean of data pointsx[i]
stored in double vectorx
.static float
mean
(float[] x) Mean of data pointsx[i]
stored in float vectorx
.static double
mean
(int[] x) Mean of data pointsx[i]
stored in integer vectorx
.static double
moment
(double[] x, int m) m
-th moment of data pointsx[i]
stored in double vectorx
.static void
popMeanVar
(double[] meanvar, double x) Remove samplex
from running (or online) mean and variance.static void
pushMeanVar
(double[] meanvar, double x) Add samplex
to running (or online) mean and variance.static double
skewness
(double[] x) Sample skewness of data pointsx[i]
stored in double vectorx
.static double
skewness
(double[] x, double m1) Sample skewness of data pointsx[i]
stored in double vectorx
with known meanm1
.static double
stdev
(double[] x) (Sample) Standard deviation of data pointsx[i]
stored in double vectorx
.static double
stdev
(double[] x, double mean) (Sample) Standard deviation of data pointsx[i]
stored in double vectorx
.static double
variance
(double[] x) Sample variance of data pointsx[i]
stored in double vectorx
using one-pass algorithm based on Welford's algorithm.static double
variance
(double[] x, double mean) Sample variance of data pointsx[i]
stored in double vectorx
with knownmean
.
-
Constructor Details
-
Distributions
private Distributions()Ensure non-instantiability with private default constructor
-
-
Method Details
-
variance
public static double variance(double[] x) Sample variance of data pointsx[i]
stored in double vectorx
using one-pass algorithm based on Welford's algorithm.Note: if the mean is known/needed, it's more efficient to use
variance(double[], double)
instead.- Parameters:
x
- data vector- Returns:
- sample variance of
x
- See Also:
-
variance
public static double variance(double[] x, double mean) Sample variance of data pointsx[i]
stored in double vectorx
with knownmean
. This corresponds to the second pass of a two-pass algorithm.- Parameters:
x
- data vectormean
- ofx
- Returns:
- sample variance of
x
-
stdev
public static double stdev(double[] x) (Sample) Standard deviation of data pointsx[i]
stored in double vectorx
.- Parameters:
x
- data vector- Returns:
- sample standard deviation of
x
- See Also:
-
stdev
public static double stdev(double[] x, double mean) (Sample) Standard deviation of data pointsx[i]
stored in double vectorx
.- Parameters:
x
- data vectormean
- of data vectorx
- Returns:
- sample standard deviation of
x
- See Also:
-
covariance
public static double covariance(double[] x, double[] y) Sample covariance of data pointsx[i]
,y[i]
stored in double vectorsx
andy
using one-pass algorithm based on Welford's algorithm.Note: if the means are known/needed, it's more efficient to use
covariance(double[], double, double[], double)
instead.- Parameters:
x
- first data vectory
- second data vector- Returns:
- sample covariance of
x
andy
- See Also:
-
covariance
public static double covariance(double[] x, double meanx, double[] y, double meany) Sample covariance of data pointsx[i]
,y[i]
stored in double vectorsx
andy
with known meansmeanx
andmeany
. This corresponds to the second pass of a two-pass algorithm.- Parameters:
x
- first data vectormeanx
- the mean ofx
y
- second data vectormeany
- the mean ofy
- Returns:
- sample covariance of
x
andy
-
correlation
public static double correlation(double[] x, double[] y) Pearson correlation coefficient between data pointsx[i]
,y[i]
stored in double vectorsx
andy
using one-pass algorithm based on Welford's algorithm.Note: if the means and variances are known/needed, it's more efficient to use
correlation(double[], double, double, double[], double, double)
instead.- Parameters:
x
- first data vectory
- second data vector- Returns:
- Pearson correlation coefficient of
x
andy
- See Also:
-
correlation
public static double correlation(double[] x, double meanx, double varx, double[] y, double meany, double vary) Pearson correlation coefficient between data pointsx[i]
,y[i]
stored in double vectorsx
andy
with known meansmeanx
,meany
and variancesvarx
,vary
.- Parameters:
x
- first data vectormeanx
- the mean ofx
varx
- the variance ofx
y
- second data vectormeany
- the mean ofy
vary
- the variance ofy
- Returns:
- Pearson correlation coefficient of
x
andy
- See Also:
-
centralMoment
public static double centralMoment(double[] x, int m) m
-th centralized moment of data pointsx[i]
stored in double vectorx
. Central moments are moments about the mean. For example, the second central moment is the variance.- Parameters:
x
- data vectorm
- moment- Returns:
m
-th centralized moment ofx
-
centralMoment
public static double centralMoment(double[] x, double m1, int m) m
-th centralized moment of data pointsx[i]
stored in double vectorx
with known meanm1
. Central moments are moments about the mean. For example, the second central moment is the variance.- Parameters:
x
- data vectorm1
- mean ofx
m
- moment- Returns:
m
-th centralized moment ofx
-
skewness
public static double skewness(double[] x) Sample skewness of data pointsx[i]
stored in double vectorx
.- Parameters:
x
- data vector- Returns:
- skewness of
x
-
skewness
public static double skewness(double[] x, double m1) Sample skewness of data pointsx[i]
stored in double vectorx
with known meanm1
.- Parameters:
x
- data vectorm1
- mean ofx
- Returns:
- skewness of
x
-
kurtosis
public static double kurtosis(double[] x) Sample kurtosis of data pointsx[i]
stored in double vectorx
.- Parameters:
x
- data vector- Returns:
- kurtosis of
x
-
kurtosis
public static double kurtosis(double[] x, double m1) Sample kurtosis of data pointsx[i]
stored in double vectorx
with known meanm1
.- Parameters:
x
- data vectorm1
- mean ofx
- Returns:
- kurtosis of
x
-
bimodality
public static double bimodality(double[] x) Bimodality coefficient of data pointsx[i]
stored in double vectorx
. Coefficient lies between5/9
, for uniform and exponential distributions, and1
, for Bernoulli distributions with two distinct values or the sum of two Dirac delta functions. Values>5/9
may indicate bimodal or multimodal distributions.- Parameters:
x
- data vector- Returns:
- bimodality coefficient
- See Also:
-
bimodality
public static double bimodality(double[] x, double m1) Bimodality coefficient of data pointsx[i]
stored in double vectorx
with known meanm1
. Coefficient lies between5/9
, for uniform and exponential distributions, and1
, for Bernoulli distributions with two distinct values or the sum of two Dirac delta functions. Values>5/9
may indicate bimodal or multimodal distributions.- Parameters:
x
- data vectorm1
- mean ofx
- Returns:
- bimodality coefficient
- See Also:
-
distrMean
public static double distrMean(double[] w) Mean of probability distribution with weightsw[i]
stored in double vectorw
. This is the same as the center of mass.Note: range of events is assumed to be in
[0, 1]
, i.e. first bin at0
and last bin at1
.- Parameters:
w
- probability distribution- Returns:
- mean of
w
-
distrVariance
public static double distrVariance(double[] w) Variance of probability distribution with weightsw[i]
stored in double vectorw
. This is the same as the second central moment of the distribution.Note: range of events is assumed to be in
[0, 1]
, i.e. first bin at0
and last bin at1
.- Parameters:
w
- probability distribution- Returns:
- variance of
w
- See Also:
-
distrVariance
public static double distrVariance(double[] w, double m1) Variance of probability distribution with weightsw[i]
stored in double vectorw
with known meanm1
. This is the same as the second central moment of the distribution.Note: range of events is assumed to be in
[0, 1]
, i.e. first bin at0
and last bin at1
.- Parameters:
w
- probability distributionm1
- mean ofw
- Returns:
- variance of
w
- See Also:
-
distrStdev
public static double distrStdev(double[] w) Standard deviation of probability distribution with weightsw[i]
stored in double vectorw
.Note: range of events is assumed to be in
[0, 1]
, i.e. first bin at0
and last bin at1
.- Parameters:
w
- probability distribution- Returns:
- standard deviation of
w
- See Also:
-
distrStdev
public static double distrStdev(double[] w, double m1) Standard deviation of probability distribution with weightsw[i]
stored in double vectorw
with known meanm1
.Note: range of events is assumed to be in
[0, 1]
, i.e. first bin at0
and last bin at1
.- Parameters:
w
- probability distributionm1
- mean ofw
- Returns:
- standard deviation of
w
- See Also:
-
distrMoment
public static double distrMoment(double[] w, int m) m
-th moment of probability distribution with weightsw[i]
stored in double vectorw
.Note: range of events is assumed to be in
[0, 1]
, i.e. first bin at0
and last bin at1
.- Parameters:
w
- probability distributionm
- moment- Returns:
m
-th moment ofw
-
distrCentralMoment
public static double distrCentralMoment(double[] w, int m) m
-th central moment of probability distribution with weightsw[i]
stored in double vectorw
.Note: range of events is assumed to be in
[0, 1]
, i.e. first bin at0
and last bin at1
.- Parameters:
w
- probability distributionm
- moment- Returns:
m
-th moment ofw
-
distrCentralMoment
public static double distrCentralMoment(double[] w, int m, double m1) m
-th central moment of probability distribution with weightsw[i]
stored in double vectorw
with known meanm1
.Note: range of events is assumed to be in
[0, 1]
, i.e. first bin at0
and last bin at1
.- Parameters:
w
- probability distributionm
- momentm1
- mean ofw
- Returns:
m
-th moment ofw
- See Also:
-
mean
public static double mean(int[] x) Mean of data pointsx[i]
stored in integer vectorx
.- Parameters:
x
- data vector- Returns:
- mean of
x
-
mean
public static float mean(float[] x) Mean of data pointsx[i]
stored in float vectorx
.- Parameters:
x
- data vector- Returns:
- mean of
x
-
mean
public static double mean(double[] x) Mean of data pointsx[i]
stored in double vectorx
.- Parameters:
x
- data vector- Returns:
- mean of
x
-
moment
public static double moment(double[] x, int m) m
-th moment of data pointsx[i]
stored in double vectorx
.- Parameters:
x
- data vectorm
- moment- Returns:
m
-th moment ofx
-
pushMeanVar
public static void pushMeanVar(double[] meanvar, double x) Add samplex
to running (or online) mean and variance. The entries in themeanvar
array are[mean, M2, count]
, whereM2
refers to the second central moment such thatM2/(count-1)
is the sample variance.- Parameters:
meanvar
- the array with the running valuesx
- the sample- See Also:
-
popMeanVar
public static void popMeanVar(double[] meanvar, double x) Remove samplex
from running (or online) mean and variance. The entries in themeanvar
array are[mean, M2, count]
, whereM2
refers to the second central moment such thatM2/(count-1)
is the sample variance.- Parameters:
meanvar
- the array with the running valuesx
- the sample- See Also:
-