Class 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 independence
      static double[] chiSquareTest​(ucar.ma2.Array e, ucar.ma2.Array o)
      Chi-square test
      static java.lang.Object cov​(ucar.ma2.Array a, boolean bias)
      Computes covariances for columns of a matrix.
      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.
      static double covariance​(ucar.ma2.Array x, ucar.ma2.Array y, boolean bias)
      Computes covariance of two arrays.
      static double kendalltau​(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 double percentile​(ucar.ma2.Array a, double p)
      Returns an estimate of the pth percentile of the values in the array.
      static ucar.ma2.Array percentile​(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.Object spearmanr​(ucar.ma2.Array a)
      Computes Spearman's rank correlation for columns of a matrix.
      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.
      static double[] tTest​(ucar.ma2.Array a, double mu)
      One sample t test
      static double[] tTest​(ucar.ma2.Array a, ucar.ma2.Array b)
      unpaired, two-sided, two-sample t-test.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StatsUtil

        public StatsUtil​()
    • 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 data
        y - Y data
        bias - 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 data
        y - Y data
        bias - 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 data
        bias - 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 data
        y - 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 data
        y - 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 data
        y - 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 array
        x - 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 array
        x - X sample data - two dimension array
        noIntercept - 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 array
        p - 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.InvalidRangeException
        Returns an estimate of the pth percentile of the values in the array along an axis.
        Parameters:
        a - Input array
        p - The percentile value to compute
        axis - 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 data
        mu - 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