Package org.cicirello.math.stats
Class Statistics
- java.lang.Object
-
- org.cicirello.math.stats.Statistics
-
public final class Statistics extends Object
Utility class of basic statistics.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublecorrelation(double[] X, double[] Y)Computes correlation coefficient for a pair of random variables.static doublecorrelation(int[] X, int[] Y)Computes correlation coefficient for a pair of random variables.static double[][]correlationMatrix(double[][] data)Computes correlation matrix.static double[][]correlationMatrix(int[][] data)Computes correlation matrix.static doublecovariance(double[] X, double[] Y)Computes covariance for a pair of random variables.static doublecovariance(int[] X, int[] Y)Computes covariance for a pair of random variables.static doublemean(double[] data)Computes mean of a dataset.static doublemean(int[] data)Computes mean of a dataset.static doubletTestUnequalVariances(double[] data1, double[] data2)Welch's t-test, also known as t-test with unequal variances.static doubletTestUnequalVariances(int[] data1, int[] data2)Welch's t-test, also known as t-test with unequal variances.static Number[]tTestWelch(double[] data1, double[] data2)Welch's t-test, also known as t-test with unequal variances.static Number[]tTestWelch(int[] data1, int[] data2)Welch's t-test, also known as t-test with unequal variances.static doublevariance(double[] data)Computes variance of a population.static doublevariance(int[] data)Computes variance of a population.static doublevarianceSample(double[] data)Computes variance of a sample.static doublevarianceSample(int[] data)Computes variance of a sample.
-
-
-
Method Detail
-
mean
public static double mean(int[] data)
Computes mean of a dataset.- Parameters:
data- The dataset.- Returns:
- the mean of the data.
-
mean
public static double mean(double[] data)
Computes mean of a dataset.- Parameters:
data- The dataset.- Returns:
- the mean of the data.
-
variance
public static double variance(int[] data)
Computes variance of a population.- Parameters:
data- The dataset.- Returns:
- the variance of the data.
-
variance
public static double variance(double[] data)
Computes variance of a population.- Parameters:
data- The dataset.- Returns:
- the variance of the data.
-
varianceSample
public static double varianceSample(int[] data)
Computes variance of a sample.- Parameters:
data- The dataset.- Returns:
- the variance of the data.
-
varianceSample
public static double varianceSample(double[] data)
Computes variance of a sample.- Parameters:
data- The dataset.- Returns:
- the variance of the data.
-
covariance
public static double covariance(int[] X, int[] Y)Computes covariance for a pair of random variables.- Parameters:
X- Array of samples of first variable.Y- Array of samples of second variable.- Returns:
- the covariance of X and Y.
-
covariance
public static double covariance(double[] X, double[] Y)Computes covariance for a pair of random variables.- Parameters:
X- Array of samples of first variable.Y- Array of samples of second variable.- Returns:
- the covariance of X and Y.
-
correlation
public static double correlation(int[] X, int[] Y)Computes correlation coefficient for a pair of random variables.- Parameters:
X- Array of samples of first variable.Y- Array of samples of second variable.- Returns:
- the correlation coefficient of X and Y.
-
correlation
public static double correlation(double[] X, double[] Y)Computes correlation coefficient for a pair of random variables.- Parameters:
X- Array of samples of first variable.Y- Array of samples of second variable.- Returns:
- the correlation coefficient of X and Y.
-
correlationMatrix
public static double[][] correlationMatrix(int[][] data)
Computes correlation matrix.- Parameters:
data- The data with random variables in rows and samples in columns.- Returns:
- the correlation matrix, M, where M[i][j] is the correlation coefficient of data[i] and data[j].
-
correlationMatrix
public static double[][] correlationMatrix(double[][] data)
Computes correlation matrix.- Parameters:
data- The data with random variables in rows and samples in columns.- Returns:
- the correlation matrix, M, where M[i][j] is the correlation coefficient of data[i] and data[j].
-
tTestUnequalVariances
public static double tTestUnequalVariances(double[] data1, double[] data2)Welch's t-test, also known as t-test with unequal variances. The Welch's t-test can be used when variances are unequal and is also applicable if sample sizes differ.- Parameters:
data1- First dataset.data2- Second dataset.- Returns:
- The t statistic.
-
tTestUnequalVariances
public static double tTestUnequalVariances(int[] data1, int[] data2)Welch's t-test, also known as t-test with unequal variances. The Welch's t-test can be used when variances are unequal and is also applicable if sample sizes differ.- Parameters:
data1- First dataset.data2- Second dataset.- Returns:
- The t statistic.
-
tTestWelch
public static Number[] tTestWelch(double[] data1, double[] data2)
Welch's t-test, also known as t-test with unequal variances. The Welch's t-test can be used when variances are unequal and is also applicable if sample sizes differ. This method computes both the t statistic, as well as the approximate degrees of freedom.- Parameters:
data1- First dataset.data2- Second dataset.- Returns:
- An array, a, of length 2 such that a[0] is the t statistic (as a Double object), and a[1] is the degrees of freedom (as an Integer object).
-
tTestWelch
public static Number[] tTestWelch(int[] data1, int[] data2)
Welch's t-test, also known as t-test with unequal variances. The Welch's t-test can be used when variances are unequal and is also applicable if sample sizes differ. This method computes both the t statistic, as well as the approximate degrees of freedom.- Parameters:
data1- First dataset.data2- Second dataset.- Returns:
- An array, a, of length 2 such that a[0] is the t statistic (as a Double object), and a[1] is the degrees of freedom (as an Integer object).
-
-