Package org.meteoinfo.math.stats
Class StatsUtil
- java.lang.Object
-
- org.meteoinfo.math.stats.StatsUtil
-
public class StatsUtil extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description StatsUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double[]chiSquareTest(ucar.ma2.Array o)Chi-square test of independencestatic double[]chiSquareTest(ucar.ma2.Array e, ucar.ma2.Array o)Chi-square teststatic java.lang.Objectcov(ucar.ma2.Array a, boolean bias)Computes covariances for columns of a matrix.static ucar.ma2.Arraycov(ucar.ma2.Array x, ucar.ma2.Array y, boolean bias)Computes covariances for pairs of arrays or columns of a matrix.static doublecovariance(ucar.ma2.Array x, ucar.ma2.Array y, boolean bias)Computes covariance of two arrays.static doublekendalltau(ucar.ma2.Array x, ucar.ma2.Array y)Calculates Kendall's tau, a correlation measure for ordinal data.static ucar.ma2.Array[]multipleLineRegress_OLS(ucar.ma2.Array y, ucar.ma2.Array x)Implements ordinary least squares (OLS) to estimate the parameters of a multiple linear regression model.static ucar.ma2.Array[]multipleLineRegress_OLS(ucar.ma2.Array y, ucar.ma2.Array x, boolean noIntercept)Implements ordinary least squares (OLS) to estimate the parameters of a multiple linear regression model.static double[]pairedTTest(ucar.ma2.Array a, ucar.ma2.Array b)Paired test evaluating the null hypothesis that the mean difference between corresponding (paired) elements of the double[] arrays sample1 and sample2 is zero.static double[]pearsonr(ucar.ma2.Array x, ucar.ma2.Array y)Calculates a Pearson correlation coefficient.static doublepercentile(ucar.ma2.Array a, double p)Returns an estimate of the pth percentile of the values in the array.static ucar.ma2.Arraypercentile(ucar.ma2.Array a, double p, int axis)Returns an estimate of the pth percentile of the values in the array along an axis.static java.lang.Objectspearmanr(ucar.ma2.Array a)Computes Spearman's rank correlation for columns of a matrix.static ucar.ma2.Arrayspearmanr(ucar.ma2.Array x, ucar.ma2.Array y)Computes Spearman's rank correlation for pairs of arrays or columns of a matrix.static double[]tTest(ucar.ma2.Array a, double mu)One sample t teststatic double[]tTest(ucar.ma2.Array a, ucar.ma2.Array b)unpaired, two-sided, two-sample t-test.
-
-
-
Method Detail
-
covariance
public static double covariance(ucar.ma2.Array x, ucar.ma2.Array y, boolean bias)Computes covariance of two arrays.- Parameters:
x- X datay- Y databias- If true, returned value will be bias-corrected- Returns:
- The covariance
-
cov
public static ucar.ma2.Array cov(ucar.ma2.Array x, ucar.ma2.Array y, boolean bias)Computes covariances for pairs of arrays or columns of a matrix.- Parameters:
x- X datay- Y databias- If true, returned value will be bias-corrected- Returns:
- The covariance matrix
-
cov
public static java.lang.Object cov(ucar.ma2.Array a, boolean bias)Computes covariances for columns of a matrix.- Parameters:
a- Matrix databias- If true, returned value will be bias-corrected- Returns:
- Covariant matrix or value
-
kendalltau
public static double kendalltau(ucar.ma2.Array x, ucar.ma2.Array y)Calculates Kendall's tau, a correlation measure for ordinal data.- Parameters:
x- X datay- Y data- Returns:
- Kendall's tau correlation.
-
pearsonr
public static double[] pearsonr(ucar.ma2.Array x, ucar.ma2.Array y)Calculates a Pearson correlation coefficient.- Parameters:
x- X datay- Y data- Returns:
- Pearson correlation and p-value.
-
spearmanr
public static ucar.ma2.Array spearmanr(ucar.ma2.Array x, ucar.ma2.Array y)Computes Spearman's rank correlation for pairs of arrays or columns of a matrix.- Parameters:
x- X datay- Y data- Returns:
- Spearman's rank correlation
-
spearmanr
public static java.lang.Object spearmanr(ucar.ma2.Array a)
Computes Spearman's rank correlation for columns of a matrix.- Parameters:
a- Matrix data- Returns:
- Spearman's rank correlation
-
multipleLineRegress_OLS
public static ucar.ma2.Array[] multipleLineRegress_OLS(ucar.ma2.Array y, ucar.ma2.Array x)Implements ordinary least squares (OLS) to estimate the parameters of a multiple linear regression model.- Parameters:
y- Y sample data - one dimension arrayx- X sample data - two dimension array- Returns:
- Estimated regression parameters and residuals
-
multipleLineRegress_OLS
public static ucar.ma2.Array[] multipleLineRegress_OLS(ucar.ma2.Array y, ucar.ma2.Array x, boolean noIntercept)Implements ordinary least squares (OLS) to estimate the parameters of a multiple linear regression model.- Parameters:
y- Y sample data - one dimension arrayx- X sample data - two dimension arraynoIntercept- No intercept- Returns:
- Estimated regression parameters and residuals
-
percentile
public static double percentile(ucar.ma2.Array a, double p)Returns an estimate of the pth percentile of the values in the array.- Parameters:
a- Input arrayp- The percentile value to compute- Returns:
- The pth percentile
-
percentile
public static ucar.ma2.Array percentile(ucar.ma2.Array a, double p, int axis) throws ucar.ma2.InvalidRangeExceptionReturns an estimate of the pth percentile of the values in the array along an axis.- Parameters:
a- Input arrayp- The percentile value to computeaxis- The axis- Returns:
- The pth percentile
- Throws:
ucar.ma2.InvalidRangeException
-
tTest
public static double[] tTest(ucar.ma2.Array a, double mu)One sample t test- Parameters:
a- Input datamu- Expected value in null hypothesis- Returns:
- t_statistic and p_value
-
tTest
public static double[] tTest(ucar.ma2.Array a, ucar.ma2.Array b)unpaired, two-sided, two-sample t-test.- Parameters:
a- Sample a.b- Sample b.- Returns:
- t_statistic and p_value
-
pairedTTest
public static double[] pairedTTest(ucar.ma2.Array a, ucar.ma2.Array b)Paired test evaluating the null hypothesis that the mean difference between corresponding (paired) elements of the double[] arrays sample1 and sample2 is zero.- Parameters:
a- Sample a.b- Sample b.- Returns:
- t_statistic and p_value
-
chiSquareTest
public static double[] chiSquareTest(ucar.ma2.Array e, ucar.ma2.Array o)Chi-square test- Parameters:
e- Expected.o- Observed.- Returns:
- Chi-square_statistic and p_value
-
chiSquareTest
public static double[] chiSquareTest(ucar.ma2.Array o)
Chi-square test of independence- Parameters:
o- Observed.- Returns:
- Chi-square_statistic and p_value
-
-