Class StatUtils
- gamma
- internalGamma
- beta
- igamma
- erf
- poisson
- chidist
- contTable1
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
averageDeviation
(double[] array) averageDeviation.static double
averageDeviation
(double[] array, int N) averageDeviation.static double
averageDeviation
(long[] array) averageDeviation.static double
averageDeviation
(long[] array, int N) averageDeviation.static double
basisFunctionValue
(int type, int index, double x) Performs a calculation that involves repeatedly multiplying an initial value of `1.0` by the product of `0.95` and a given parameter `x`, iterating `index` times.static double
beta
(double x1, double x2) Calculates the value of beta for doublesstatic double
calculateCentralMoment
(double[] data, int i) static double
calculateCumulant
(double[] data, int i) static double
calculateMoment
(double[] data, int i) static double
chebyshev
(int index, double x) Computes the value of the Chebyshev polynomial of a given degree at a specified point x.static double
chidist
(double x, int degreesOfFreedom) Calculates the one-tail probability of the Chi-squared distribution for doublesstatic short
compressedCorrelation
(Vector data1, Vector data2) compressedCorrelation.static double
correlation
(double[] array1, double[] array2) correlation.static double
correlation
(double[] array1, double[] array2, int N) correlation.static double
correlation
(long[] array1, long[] array2) correlation.static double
correlation
(long[] array1, long[] array2, int N) correlation.static double
correlation
(Vector data1, Vector data2) correlation.static double[]
cov
(double[] x, double[] y, double[] condition, double threshold, double direction) cov.static double
covariance
(double[] array1, double[] array2) covariance.static double
covariance
(double[] array1, double[] array2, int N) covariance.static double
covariance
(long[] array1, long[] array2) covariance.static double
covariance
(long[] array1, long[] array2, int N) covariance.static double[][]
covMatrix
(double[] x, double[] y, double[][] z, double[] condition, double threshold, double direction) covMatrix.static int
dieToss
(int n) dieToss.static double[]
E
(double[] x, double[] y, double[] condition, double threshold, double direction) E.static double
entropy
(int numBins, double[] _f) entropy.static double
erf
(double x) Calculates the error function for a doublestatic double
expScore
(double[] _f) expScore.static double
factorial
(int c) factorial.static int
fdr.static int
fdr.static double
fdrCutoff.static double
Calculates the cutoff value for p-values using the FDR method.static double
fdrCutoff
(double alpha, List<Double> pValues, int[] _k, boolean negativelyCorrelated, boolean pSorted) fdrCutoff.static double
fdrQ.static double
gamma
(double z) GAMMA FUNCTION (From DStat, used by permission).static double[]
getRanks
(double[] arr) getRanks.getRows
(double[] x, double[] condition, double threshold, double direction) getRows.getRows
(double[] x, double threshold, double direction) getRows.static double
getZForAlpha
(double alpha) getZForAlpha.static double
hermite1
(int index, double x) Computes the (statitician's) Hermite polynomial of a given index and value.static double
hermite2
(int index, double x) Computes the (physicis's) Hermite polynomial of a given index and value.static double
igamma
(double a, double x) Calculates the incomplete gamma function for two doublesstatic double
kendallsTau
(double[] x, double[] y) kendallsTau.static double
kurtosis
(double[] array) kurtosis.static double
kurtosis
(double[] array, int N) kurtosis.static double
kurtosis
(long[] array) kurtosis.static double
kurtosis
(long[] array, int N) kurtosis.static double
legendre
(int index, double x) Computes the value of the Legendre polynomial of a given degree at a specified point x.static double
logCoshExp.static double
logCoshScore
(double[] _f) logCoshScore.static double
logsum.static double
max
(double[] array) max.static double
max
(double[] array, int N) max.static double
max
(long[] array) max.static double
max
(long[] array, int N) max.static double
maxEntApprox
(double[] x) maxEntApprox.static double
mean
(double[] array) mean.static double
mean
(double[] array, int N) mean.static double
mean
(long[] array) mean.static double
mean
(long[] array, int N) mean.static double
mean.static double
meanAbsolute
(double[] _f) meanAbsolute.static double
median
(double[] array) median.static double
median
(double[] array, int N) median.static double
median
(long[] array) median.static long
median
(long[] array, int N) median.static double
min
(double[] array) min.static double
min
(double[] array, int N) min.static double
min
(long[] array) min.static double
min
(long[] array, int N) min.static double
mu
(double[] array) mu.static double
mu
(double[] array, int N) mu.static double
mu
(long[] array) mu.static double
mu
(long[] array, int N) mu.static double
muHat
(double[] array) muHat.static double
muHat
(double[] array, int N) muHat.static double
muHat
(long[] array) muHat.static double
muHat
(long[] array, int N) muHat.static int
N
(double[] array) N.static int
N
(long[] array) N.static double
partialCorrelation
(Matrix submatrix) Assumes that the given covariance matrix was extracted in such a way that the order of the variables (in either direction) is X, Y, Z1, ..., Zn, where the partial correlation one wants is correlation(X, Y | Z1,...,Zn).static double
partialCorrelation
(Matrix covariance, int x, int y, int... z) partialCorrelation.static double
partialCorrelationPrecisionMatrix
(Matrix submatrix) partialCorrelationPrecisionMatrix.static double
partialCovarianceWhittaker
(Matrix submatrix) Assumes that the given covariance matrix was extracted in such a way that the order of the variables (in either direction) is X, Y, Z1, ..., Zn, where the partial covariance one wants is covariance(X, Y | Z1,...,Zn).static double
partialCovarianceWhittaker
(Matrix covariance, int x, int y, int... z) partialCovarianceWhittaker.static double
partialStandardDeviation
(Matrix covariance, int x, int... z) partialStandardDeviation.static double
partialVariance
(Matrix covariance, int x, int... z) partialVariance.static double
poisson
(double k, double x, boolean cum) Calculates the Poisson Distribution for mean x and k events for doubles.static double
pow()
pow.static double
quartile
(double[] array, int quartileNumber) quartile.static double
quartile
(double[] array, int N, int quartileNumber) quartile.static double
quartile
(long[] array, int quartileNumber) quartile.static double
quartile
(long[] array, int N, int quartileNumber) quartile.static double
range
(double[] array) range.static double
range
(double[] array, int N) range.static double
range
(long[] array) range.static double
range
(long[] array, int N) range.static double
rankCorrelation
(double[] arr1, double[] arr2) rankCorrelation.static double[]
removeNaN
(double[] x1) removeNaN.static double
sd
(double[] array) sd.static double
sd
(double[] array, int N) sd.static double
sd
(long[] array) sd.static double
sd
(long[] array, int N) sd.static double
skewness
(double[] array) skewness.static double
skewness
(double[] array, int N) skewness.static double
skewness
(long[] array) skewness.static double
skewness
(long[] array, int N) skewness.static double
sSquare
(double[] array) sSquare.static double
sSquare
(double[] array, int N) sSquare.static double
sSquare
(long[] array) sSquare.static double
sSquare
(long[] array, int N) sSquare.static double
ssx
(double[] array) ssx.static double
ssx
(double[] array, int N) ssx.static double
ssx
(long[] array) ssx.static double
ssx
(long[] array, int N) ssx.static double[]
standardizeData
(double[] data) standardizeData.static double
standardizedFifthMoment
(double[] array) standardizedFifthMoment.static double
standardizedFifthMoment
(double[] array, int N) standardizedFifthMoment.static double
standardizedSixthMoment
(double[] array) standardizedSixthMoment.static double
standardizedSixthMoment
(double[] array, int N) standardizedSixthMoment.static double
sum
(double[] x) sum.static double
sxy
(double[] array1, double[] array2) sxy.static double
sxy
(double[] array1, double[] array2, int N) sxy.static double
sxy
(long[] array1, long[] array2) sxy.static double
sxy
(long[] array1, long[] array2, int N) sxy.static double
sxy.static double
varHat
(double[] array) varHat.static double
varHat
(double[] array, int N) varHat.static double
varHat
(long[] array) varHat.static double
varHat
(long[] array, int N) varHat.static double
variance
(double[] array) variance.static double
variance
(double[] array, int N) variance.static double
variance
(long[] array) variance.static double
variance
(long[] array, int N) variance.
-
Method Details
-
mean
public static double mean(long[] array) mean.
- Parameters:
array
- a long array.- Returns:
- the mean of the values in this array.
-
mean
public static double mean(double[] array) mean.
- Parameters:
array
- a double array.- Returns:
- the mean of the values in this array.
-
mean
public static double mean(long[] array, int N) mean.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the mean of the first N values in this array.
-
mean
public static double mean(double[] array, int N) mean.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the mean of the first N values in this array.
-
mean
mean.
- Parameters:
data
- a column vector.N
- the number of values of array which should be considered.- Returns:
- the mean of the first N values in this array.
-
median
public static double median(long[] array) median.
- Parameters:
array
- a long array.- Returns:
- the median of the values in this array.
-
median
public static double median(double[] array) median.
- Parameters:
array
- a double array.- Returns:
- the median of the values in this array.
-
median
public static long median(long[] array, int N) median.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the median of the first N values in this array.
-
median
public static double median(double[] array, int N) median.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the median of the first N values in this array.
-
quartile
public static double quartile(long[] array, int quartileNumber) quartile.
- Parameters:
array
- a long array.quartileNumber
- 1, 2, or 3.- Returns:
- the requested quartile of the values in this array.
-
quartile
public static double quartile(double[] array, int quartileNumber) quartile.
- Parameters:
array
- a double array.quartileNumber
- 1, 2, or 3.- Returns:
- the requested quartile of the values in this array.
-
quartile
public static double quartile(long[] array, int N, int quartileNumber) quartile.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.quartileNumber
- 1, 2, or 3.- Returns:
- the requested quartile of the first N values in this array.
-
quartile
public static double quartile(double[] array, int N, int quartileNumber) quartile.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.quartileNumber
- 1, 2, or 3.- Returns:
- the requested quartile of the first N values in this array.
-
min
public static double min(long[] array) min.
- Parameters:
array
- a long array.- Returns:
- the minimum of the values in this array.
-
min
public static double min(double[] array) min.
- Parameters:
array
- a double array.- Returns:
- the minimum of the values in this array.
-
min
public static double min(long[] array, int N) min.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the minimum of the first N values in this array.
-
min
public static double min(double[] array, int N) min.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the minimum of the first N values in this array.
-
max
public static double max(long[] array) max.
- Parameters:
array
- a long array.- Returns:
- the maximum of the values in this array.
-
max
public static double max(double[] array) max.
- Parameters:
array
- a double array.- Returns:
- the maximum of the values in this array.
-
max
public static double max(long[] array, int N) max.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the maximum of the first N values in this array.
-
max
public static double max(double[] array, int N) max.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the maximum of the first N values in this array.
-
range
public static double range(long[] array) range.
- Parameters:
array
- a long array.- Returns:
- the range of the values in this array.
-
range
public static double range(double[] array) range.
- Parameters:
array
- a double array.- Returns:
- the range of the values in this array.
-
range
public static double range(long[] array, int N) range.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the range of the first N values in this array.
-
range
public static double range(double[] array, int N) range.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the range of the first N values in this array.
-
N
public static int N(long[] array) N.
- Parameters:
array
- a long array.- Returns:
- the length of this array.
-
N
public static int N(double[] array) N.
- Parameters:
array
- a double array.- Returns:
- the length of this array.
-
ssx
public static double ssx(long[] array) ssx.
- Parameters:
array
- a long array.- Returns:
- the sum of the squared differences from the mean in array.
-
ssx
public static double ssx(double[] array) ssx.
- Parameters:
array
- a double array.- Returns:
- the sum of the squared differences from the mean in array.
-
ssx
public static double ssx(long[] array, int N) ssx.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the sum of the squared differences from the mean of the first N values in array.
-
ssx
public static double ssx(double[] array, int N) ssx.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the sum of the squared differences from the mean of the first N values in array.
-
sxy
public static double sxy(long[] array1, long[] array2) sxy.
- Parameters:
array1
- a long array.array2
- a long array, same length as array1.- Returns:
- the sum of the squared differences of the products from the products of the sample means for array1 and array2..
-
sxy
public static double sxy(double[] array1, double[] array2) sxy.
- Parameters:
array1
- a double array.array2
- a double array, same length as array1.- Returns:
- the sum of the squared differences of the products from the products of the sample means for array1 and array2..
-
sxy
public static double sxy(long[] array1, long[] array2, int N) sxy.
- Parameters:
array1
- a long array.array2
- a long array.N
- the number of values of array which should be considered.- Returns:
- the sum of the squared differences of the products from the products of the sample means for the first N values in array1 and array2..
-
sxy
public static double sxy(double[] array1, double[] array2, int N) sxy.
- Parameters:
array1
- a double array.array2
- a double array.N
- the number of values of array which should be considered.- Returns:
- the sum of the squared differences of the products from the products of the sample means for the first N values in array1 and array2..
-
sxy
sxy.
- Parameters:
data1
- a column vector of doubles.data2
- a column vector of doubles.N
- the number of values of array which should be considered.- Returns:
- the sum of the squared differences of the products from the products of the sample means for the first N values in array1 and array2..
-
variance
public static double variance(long[] array) variance.
- Parameters:
array
- a long array.- Returns:
- the variance of the values in array.
-
variance
public static double variance(double[] array) variance.
- Parameters:
array
- a double array.- Returns:
- the variance of the values in array.
-
variance
public static double variance(long[] array, int N) variance.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the variance of the first N values in array.
-
variance
public static double variance(double[] array, int N) variance.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the variance of the first N values in array.
-
sd
public static double sd(long[] array) sd.
- Parameters:
array
- a long array.- Returns:
- the standard deviation of the values in array.
-
sd
public static double sd(double[] array) sd.
- Parameters:
array
- a double array.- Returns:
- the standard deviation of the values in array.
-
sd
public static double sd(long[] array, int N) sd.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the standard deviation of the first N values in array.
-
sd
public static double sd(double[] array, int N) sd.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the standard deviation of the first N values in array.
-
covariance
public static double covariance(long[] array1, long[] array2) covariance.
- Parameters:
array1
- a long array.array2
- a second long array (same length as array1).- Returns:
- the covariance of the values in array.
-
covariance
public static double covariance(double[] array1, double[] array2) covariance.
- Parameters:
array1
- a double array.array2
- a second double array (same length as array1).- Returns:
- the covariance of the values in array.
-
covariance
public static double covariance(long[] array1, long[] array2, int N) covariance.
- Parameters:
array1
- a long array.array2
- a second long array.N
- the number of values to be considered in array1 and array2.- Returns:
- the covariance of the first N values in array1 and array2.
-
covariance
public static double covariance(double[] array1, double[] array2, int N) covariance.
- Parameters:
array1
- a double array.array2
- a second double array (same length as array1).N
- the number of values to be considered in array1 and array2.- Returns:
- the covariance of the first N values in array1 and array2.
-
correlation
public static double correlation(long[] array1, long[] array2) correlation.
- Parameters:
array1
- a long array.array2
- a second long array (same length as array1).- Returns:
- the Pearson's correlation of the values in array1 and array2.
-
correlation
public static double correlation(double[] array1, double[] array2) correlation.
- Parameters:
array1
- a double array.array2
- a second double array (same length as array1).- Returns:
- the Pearson's correlation of the values in array1 and array2.
-
correlation
-
compressedCorrelation
-
correlation
public static double correlation(long[] array1, long[] array2, int N) correlation.
- Parameters:
array1
- a long array.array2
- a second long array.N
- the number of values to be considered in array1 and array2.- Returns:
- the Pearson's correlation of the first N values in array1 and array2.
-
correlation
public static double correlation(double[] array1, double[] array2, int N) correlation.
- Parameters:
array1
- a double array.array2
- a second double array.N
- the number of values to be considered in array1 and array2.- Returns:
- the Pearson correlation of the first N values in array1 and array2.
-
rankCorrelation
public static double rankCorrelation(double[] arr1, double[] arr2) rankCorrelation.
- Parameters:
arr1
- an array of objectsarr2
- an array of objects- Returns:
- a double
-
kendallsTau
public static double kendallsTau(double[] x, double[] y) kendallsTau.
- Parameters:
x
- an array of objectsy
- an array of objects- Returns:
- a double
-
getRanks
public static double[] getRanks(double[] arr) getRanks.
- Parameters:
arr
- an array of objects- Returns:
- an array of objects
-
sSquare
public static double sSquare(long[] array) sSquare.
- Parameters:
array
- a long array.- Returns:
- the unbaised estimate of the variance of the distribution of the values in array asuming the mean is unknown.
-
sSquare
public static double sSquare(double[] array) sSquare.
- Parameters:
array
- a double array.- Returns:
- the unbaised estimate of the variance of the distribution of the values in array asuming the mean is unknown.
-
sSquare
public static double sSquare(long[] array, int N) sSquare.
- Parameters:
array
- a long array.N
- the number of values to be considered in array.- Returns:
- the unbaised estimate of the variance of the distribution of the first N values in array asuming the mean is unknown.
-
sSquare
public static double sSquare(double[] array, int N) sSquare.
- Parameters:
array
- a double array.N
- the number of values to be considered in array.- Returns:
- the unbaised estimate of the variance of the distribution of the first N values in array asuming the mean is unknown.
-
varHat
public static double varHat(long[] array) varHat.
- Parameters:
array
- a long array.- Returns:
- the unbaised estimate of the variance of the distribution of the values in array asuming the mean is known.
-
varHat
public static double varHat(double[] array) varHat.
- Parameters:
array
- a double array.- Returns:
- the unbaised estimate of the variance of the distribution of the values in array asuming the mean is known.
-
varHat
public static double varHat(long[] array, int N) varHat.
- Parameters:
array
- a long array.N
- the number of values to be considered in array.- Returns:
- the unbaised estimate of the variance of the distribution of the first N values in array asuming the mean is known.
-
varHat
public static double varHat(double[] array, int N) varHat.
- Parameters:
array
- a double array.N
- the number of values to be considered in array.- Returns:
- the unbaised estimate of the variance of the distribution of the first N values in array asuming the mean is known.
-
mu
public static double mu(long[] array) mu.
- Parameters:
array
- a long array.- Returns:
- the unbaised estimate of the mean of the distribution of the values in array.
-
mu
public static double mu(double[] array) mu.
- Parameters:
array
- a double array.- Returns:
- the unbaised estimate of the mean of the distribution of the values in array.
-
mu
public static double mu(long[] array, int N) mu.
- Parameters:
array
- a long array.N
- the number of values to be considered in array.- Returns:
- the unbaised estimate of the mean of the distribution of the first N values in array.
-
mu
public static double mu(double[] array, int N) mu.
- Parameters:
array
- a double array.N
- the number of values to be considered in array.- Returns:
- the unbaised estimate of the mean of the distribution of the first N values in array.
-
muHat
public static double muHat(long[] array) muHat.
- Parameters:
array
- a long array.- Returns:
- the maximum likelihood estimate of the mean of the distribution of the values in array.
-
muHat
public static double muHat(double[] array) muHat.
- Parameters:
array
- a double array.- Returns:
- the maximum likelihood estimate of the mean of the distribution of the values in array.
-
muHat
public static double muHat(long[] array, int N) muHat.
- Parameters:
array
- a long array.N
- the number of values to be considered in array.- Returns:
- the maximum likelihood estimate of the mean of the distribution of the first N values in array.
-
muHat
public static double muHat(double[] array, int N) muHat.
- Parameters:
array
- a long array.N
- the number of values to be considered in array.- Returns:
- the maximum likelihood estimate of the mean of the distribution of the first N values in array.
-
averageDeviation
public static double averageDeviation(long[] array) averageDeviation.
- Parameters:
array
- a long array.- Returns:
- the average deviation of the values in array.
-
averageDeviation
public static double averageDeviation(double[] array) averageDeviation.
- Parameters:
array
- a double array.- Returns:
- the average deviation of the values in array.
-
averageDeviation
public static double averageDeviation(long[] array, int N) averageDeviation.
- Parameters:
array
- a long array.N
- the number of values to be considered in array.- Returns:
- the average deviation of the first N values in array.
-
averageDeviation
public static double averageDeviation(double[] array, int N) averageDeviation.
- Parameters:
array
- a double array.N
- the number of values to be considered in array.- Returns:
- the average deviation of the first N values in array.
-
calculateMoment
public static double calculateMoment(double[] data, int i) -
calculateCentralMoment
public static double calculateCentralMoment(double[] data, int i) -
calculateCumulant
public static double calculateCumulant(double[] data, int i) -
skewness
public static double skewness(long[] array) skewness.
- Parameters:
array
- a long array.- Returns:
- the skew of the values in array.
-
skewness
public static double skewness(double[] array) skewness.
- Parameters:
array
- a double array.- Returns:
- the skew of the values in array.
-
skewness
public static double skewness(long[] array, int N) skewness.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the skew of the first N values in array.
-
skewness
public static double skewness(double[] array, int N) skewness.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the skew of the first N values in array.
-
removeNaN
public static double[] removeNaN(double[] x1) removeNaN.
- Parameters:
x1
- an array of objects- Returns:
- an array of objects
-
kurtosis
public static double kurtosis(long[] array) kurtosis.
- Parameters:
array
- a long array.- Returns:
- the kurtosis of the values in array.
-
kurtosis
public static double kurtosis(double[] array) kurtosis.
- Parameters:
array
- a double array.- Returns:
- the curtosis of the values in array.
-
kurtosis
public static double kurtosis(long[] array, int N) kurtosis.
- Parameters:
array
- a long array.N
- the number of values of array which should be considered.- Returns:
- the curtosis of the first N values in array.
-
standardizedFifthMoment
public static double standardizedFifthMoment(double[] array) standardizedFifthMoment.
- Parameters:
array
- an array of objects- Returns:
- a double
-
standardizedFifthMoment
public static double standardizedFifthMoment(double[] array, int N) standardizedFifthMoment.
- Parameters:
array
- an array of objectsN
- a int- Returns:
- a double
-
standardizedSixthMoment
public static double standardizedSixthMoment(double[] array) standardizedSixthMoment.
- Parameters:
array
- an array of objects- Returns:
- a double
-
standardizedSixthMoment
public static double standardizedSixthMoment(double[] array, int N) standardizedSixthMoment.
- Parameters:
array
- an array of objectsN
- a int- Returns:
- a double
-
kurtosis
public static double kurtosis(double[] array, int N) kurtosis.
- Parameters:
array
- a double array.N
- the number of values of array which should be considered.- Returns:
- the curtosis of the first N values in array.
-
gamma
public static double gamma(double z) GAMMA FUNCTION (From DStat, used by permission).Calculates the value of gamma(double z) using Handbook of Mathematical Functions AMS 55 by Abromowitz page 256.
- Parameters:
z
- nonnegative double value.- Returns:
- the gamma value of z.
-
beta
public static double beta(double x1, double x2) Calculates the value of beta for doubles- Parameters:
x1
- the first doublex2
- the second double.- Returns:
- beta(x1, x2).
-
igamma
public static double igamma(double a, double x) Calculates the incomplete gamma function for two doubles- Parameters:
a
- first double.x
- second double.- Returns:
- incomplete gamma of (a, x).
-
erf
public static double erf(double x) Calculates the error function for a double- Parameters:
x
- argument.- Returns:
- error function of this argument.
-
poisson
public static double poisson(double k, double x, boolean cum) Calculates the Poisson Distribution for mean x and k events for doubles. If third parameter is boolean true, the cumulative Poisson function is returned.- Parameters:
k
- # eventsx
- meancum
- true if the cumulative Poisson is desired.- Returns:
- the value of the Poisson (or cumPoisson) at x.
-
chidist
public static double chidist(double x, int degreesOfFreedom) Calculates the one-tail probability of the Chi-squared distribution for doubles- Parameters:
x
- a doubledegreesOfFreedom
- a int- Returns:
- value of Chi at x with the stated degrees of freedom.
-
dieToss
public static int dieToss(int n) dieToss.
- Parameters:
n
- a int- Returns:
- a int
-
fdrCutoff
public static double fdrCutoff(double alpha, List<Double> pValues, boolean negativelyCorrelated, boolean pSorted) Calculates the cutoff value for p-values using the FDR method. Hypotheses with p-values less than or equal to this cutoff should be rejected according to the test.- Parameters:
alpha
- The desired effective significance level.pValues
- An list containing p-values to be tested in positions 0, 1, ..., n. (The rest of the array is ignored.) Note: This array will not be changed by this class. Its values are copied into a separate array before sorting.negativelyCorrelated
- Whether the p-values in the arraypValues
are negatively correlated (true if yes, false if no). If they are uncorrelated, or positively correlated, a level of alpha is used; if they are not correlated, a level of alpha / SUM_i=1_n(1 / i) is used.pSorted
- a boolean- Returns:
- the FDR alpha, which is the first p-value sorted high to low to fall below a line from (1.0, level) to (0.0, 0.0). Hypotheses less than or equal to this p-value should be rejected.
-
fdrCutoff
-
fdrCutoff
-
fdr
-
fdr
-
fdrQ
-
partialCovarianceWhittaker
Assumes that the given covariance matrix was extracted in such a way that the order of the variables (in either direction) is X, Y, Z1, ..., Zn, where the partial covariance one wants is covariance(X, Y | Z1,...,Zn). This may be extracted using DataUtils.submatrix().- Parameters:
submatrix
- aMatrix
object- Returns:
- the given partial covariance.
-
partialCovarianceWhittaker
partialCovarianceWhittaker.
- Parameters:
covariance
- aMatrix
objectx
- a inty
- a intz
- a int- Returns:
- the partial covariance(x, y | z) where these represent the column/row indices of the desired variables in
covariance
-
partialVariance
-
partialStandardDeviation
-
partialCorrelation
public static double partialCorrelation(Matrix submatrix) throws org.apache.commons.math3.linear.SingularMatrixException Assumes that the given covariance matrix was extracted in such a way that the order of the variables (in either direction) is X, Y, Z1, ..., Zn, where the partial correlation one wants is correlation(X, Y | Z1,...,Zn). This may be extracted using DataUtils.submatrix().- Parameters:
submatrix
- aMatrix
object- Returns:
- the given partial correlation.
- Throws:
org.apache.commons.math3.linear.SingularMatrixException
- if any.
-
partialCorrelationPrecisionMatrix
public static double partialCorrelationPrecisionMatrix(Matrix submatrix) throws org.apache.commons.math3.linear.SingularMatrixException partialCorrelationPrecisionMatrix.
- Parameters:
submatrix
- aMatrix
object- Returns:
- a double
- Throws:
org.apache.commons.math3.linear.SingularMatrixException
- if any.
-
partialCorrelation
partialCorrelation.
- Parameters:
covariance
- aMatrix
objectx
- a inty
- a intz
- a int- Returns:
- the partial correlation(x, y | z) where these represent the column/row indices of the desired variables
in
covariance
-
logCoshScore
public static double logCoshScore(double[] _f) logCoshScore.
- Parameters:
_f
- an array of objects- Returns:
- a double
-
meanAbsolute
public static double meanAbsolute(double[] _f) meanAbsolute.
- Parameters:
_f
- an array of objects- Returns:
- a double
-
pow
public static double pow()pow.
- Returns:
- a double
-
expScore
public static double expScore(double[] _f) expScore.
- Parameters:
_f
- an array of objects- Returns:
- a double
-
logCoshExp
public static double logCoshExp()logCoshExp.
- Returns:
- a double
-
entropy
public static double entropy(int numBins, double[] _f) entropy.
- Parameters:
numBins
- a int_f
- an array of objects- Returns:
- a double
-
maxEntApprox
public static double maxEntApprox(double[] x) maxEntApprox.
- Parameters:
x
- an array of objects- Returns:
- a double
-
standardizeData
public static double[] standardizeData(double[] data) standardizeData.
- Parameters:
data
- an array of objects- Returns:
- an array of objects
-
factorial
public static double factorial(int c) factorial.
- Parameters:
c
- a int- Returns:
- a double
-
getZForAlpha
public static double getZForAlpha(double alpha) getZForAlpha.
- Parameters:
alpha
- a double- Returns:
- a double
-
logsum
-
sum
public static double sum(double[] x) sum.
- Parameters:
x
- an array of objects- Returns:
- a double
-
cov
public static double[] cov(double[] x, double[] y, double[] condition, double threshold, double direction) cov.
- Parameters:
x
- an array of objectsy
- an array of objectscondition
- an array of objectsthreshold
- a doubledirection
- a double- Returns:
- an array of objects
-
covMatrix
public static double[][] covMatrix(double[] x, double[] y, double[][] z, double[] condition, double threshold, double direction) covMatrix.
- Parameters:
x
- an array of objectsy
- an array of objectsz
- an array of objectscondition
- an array of objectsthreshold
- a doubledirection
- a double- Returns:
- an array of objects
-
getRows
-
getRows
-
E
public static double[] E(double[] x, double[] y, double[] condition, double threshold, double direction) E.
- Parameters:
x
- an array of objectsy
- an array of objectscondition
- an array of objectsthreshold
- a doubledirection
- a double- Returns:
- an array of objects
-
hermite1
public static double hermite1(int index, double x) Computes the (statitician's) Hermite polynomial of a given index and value. The Hermite polynomials are a sequence of orthogonal polynomials defined by the Rodrigues formula. They are orthogonal with respect to the weight function exp(-x^2). The Hermite polynomial of index index is denoted H_n(x).These are coded up to index 20.
- Parameters:
index
- The index of the Hermite polynomial to be computed. This must be a non-negative integer less than or equal to 20.x
- The value at which the Hermite polynomial is to be evaluated.- Returns:
- The computed value of the Hermite polynomial.
- Throws:
IllegalArgumentException
- if the index is negative or greater than 20.
-
hermite2
public static double hermite2(int index, double x) Computes the (physicis's) Hermite polynomial of a given index and value. The Hermite polynomials are a sequence of orthogonal polynomials defined by the Rodrigues formula. They are orthogonal with respect to the weight function exp(-x^2). The Hermite polynomial of index n is denoted H_n(x).- Parameters:
index
- The index of the Hermite polynomial to be computed. This must be a non-negative integer.x
- The value at which the Hermite polynomial is to be evaluated.- Returns:
- The computed value of the Hermite polynomial.
-
legendre
public static double legendre(int index, double x) Computes the value of the Legendre polynomial of a given degree at a specified point x.The Legendre polynomial is a solution to Legendre's differential equation and is used in physics and engineering, particularly in problems involving spherical coordinates.
- Parameters:
index
- the degree of the Legendre polynomial. Must be a non-negative integer.x
- the point at which the Legendre polynomial is evaluated.- Returns:
- the value of the Legendre polynomial of the given degree at the specified point x.
- Throws:
IllegalArgumentException
- if the index is negative.
-
chebyshev
public static double chebyshev(int index, double x) Computes the value of the Chebyshev polynomial of a given degree at a specified point x.- Parameters:
index
- the degree of the Chebyshev polynomial. Must be a non-negative integer.x
- the point at which the Chebyshev polynomial is evaluated.- Returns:
- the value of the Chebyshev polynomial of the given degree at the specified point x.
-
basisFunctionValue
public static double basisFunctionValue(int type, int index, double x) Performs a calculation that involves repeatedly multiplying an initial value of `1.0` by the product of `0.95` and a given parameter `x`, iterating `index` times. The type of function used in the calculation is determined by the `type` parameter. The function types are as follows:- `g(x) = x^index [Polynomial basis]
- `g(x) = hermite1(index, x) [Statician's Hermite polynomial]
- `g(x) = hermite2(index, x) [Physicist's Hermite polynomial]
- `g(x) = legendre(index, x) [Legendre polynomial]
- `g(x) = chebyshev(index, x) [Chebyshev polynomial]
- Parameters:
type
- The type of function to be used in the calculation.index
- The number of iterations to perform the multiplication.x
- The value to be multiplied by `0.95` in each iteration.- Returns:
- The result of the iterative multiplication.
-