Class Distributions
- Author:
- Christoph Hauert
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateEnsure non-instantiability with private default constructor -
Method Summary
Modifier and TypeMethodDescriptionstatic doublebimodality(double[] x) Bimodality coefficient of data pointsx[i]stored in double vectorx.static doublebimodality(double[] x, double m1) Bimodality coefficient of data pointsx[i]stored in double vectorxwith known meanm1.static doublecentralMoment(double[] x, double m1, int m) m-th centralized moment of data pointsx[i]stored in double vectorxwith known meanm1.static doublecentralMoment(double[] x, int m) m-th centralized moment of data pointsx[i]stored in double vectorx.static doublecorrelation(double[] x, double[] y) Pearson correlation coefficient between data pointsx[i],y[i]stored in double vectorsxandyusing one-pass algorithm based on Welford's algorithm.static doublecorrelation(double[] x, double meanx, double varx, double[] y, double meany, double vary) Pearson correlation coefficient between data pointsx[i],y[i]stored in double vectorsxandywith known meansmeanx,meanyand variancesvarx,vary.static doublecovariance(double[] x, double[] y) Sample covariance of data pointsx[i],y[i]stored in double vectorsxandyusing one-pass algorithm based on Welford's algorithm.static doublecovariance(double[] x, double meanx, double[] y, double meany) Sample covariance of data pointsx[i],y[i]stored in double vectorsxandywith known meansmeanxandmeany.static doubledistrCentralMoment(double[] w, int m) m-th central moment of probability distribution with weightsw[i]stored in double vectorw.static doubledistrCentralMoment(double[] w, int m, double m1) m-th central moment of probability distribution with weightsw[i]stored in double vectorwwith known meanm1.static doubledistrMean(double[] w) Mean of probability distribution with weightsw[i]stored in double vectorw.static doubledistrMoment(double[] w, int m) m-th moment of probability distribution with weightsw[i]stored in double vectorw.static doubledistrStdev(double[] w) Standard deviation of probability distribution with weightsw[i]stored in double vectorw.static doubledistrStdev(double[] w, double m1) Standard deviation of probability distribution with weightsw[i]stored in double vectorwwith known meanm1.static doubledistrVariance(double[] w) Variance of probability distribution with weightsw[i]stored in double vectorw.static doubledistrVariance(double[] w, double m1) Variance of probability distribution with weightsw[i]stored in double vectorwwith known meanm1.static doublekurtosis(double[] x) Sample kurtosis of data pointsx[i]stored in double vectorx.static doublekurtosis(double[] x, double m1) Sample kurtosis of data pointsx[i]stored in double vectorxwith known meanm1.static doublemean(double[] x) Mean of data pointsx[i]stored in double vectorx.static floatmean(float[] x) Mean of data pointsx[i]stored in float vectorx.static doublemean(int[] x) Mean of data pointsx[i]stored in integer vectorx.static doublemoment(double[] x, int m) m-th moment of data pointsx[i]stored in double vectorx.static voidpopMeanVar(double[] meanvar, double x) Remove samplexfrom running (or online) mean and variance.static voidpushMeanVar(double[] meanvar, double x) Add samplexto running (or online) mean and variance.static doubleskewness(double[] x) Sample skewness of data pointsx[i]stored in double vectorx.static doubleskewness(double[] x, double m1) Sample skewness of data pointsx[i]stored in double vectorxwith known meanm1.static doublestdev(double[] x) (Sample) Standard deviation of data pointsx[i]stored in double vectorx.static doublestdev(double[] x, double mean) (Sample) Standard deviation of data pointsx[i]stored in double vectorx.static doublevariance(double[] x) Sample variance of data pointsx[i]stored in double vectorxusing one-pass algorithm based on Welford's algorithm.static doublevariance(double[] x, double mean) Sample variance of data pointsx[i]stored in double vectorxwith 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 vectorxusing 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 vectorxwith 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 vectorsxandyusing 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
xandy - 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 vectorsxandywith known meansmeanxandmeany. This corresponds to the second pass of a two-pass algorithm.- Parameters:
x- first data vectormeanx- the mean ofxy- second data vectormeany- the mean ofy- Returns:
- sample covariance of
xandy
-
correlation
public static double correlation(double[] x, double[] y) Pearson correlation coefficient between data pointsx[i],y[i]stored in double vectorsxandyusing 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
xandy - 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 vectorsxandywith known meansmeanx,meanyand variancesvarx,vary.- Parameters:
x- first data vectormeanx- the mean ofxvarx- the variance ofxy- second data vectormeany- the mean ofyvary- the variance ofy- Returns:
- Pearson correlation coefficient of
xandy - 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 vectorxwith known meanm1. Central moments are moments about the mean. For example, the second central moment is the variance.- Parameters:
x- data vectorm1- mean ofxm- 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 vectorxwith 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 vectorxwith 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/9may 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 vectorxwith 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/9may 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 at0and 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 at0and 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 vectorwwith 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 at0and 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 at0and 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 vectorwwith known meanm1.Note: range of events is assumed to be in
[0, 1], i.e. first bin at0and 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 at0and 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 at0and 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 vectorwwith known meanm1.Note: range of events is assumed to be in
[0, 1], i.e. first bin at0and 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 samplexto running (or online) mean and variance. The entries in themeanvararray are[mean, M2, count], whereM2refers 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 samplexfrom running (or online) mean and variance. The entries in themeanvararray are[mean, M2, count], whereM2refers 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:
-