Java Utililty Methods Array Variance

List of utility methods to do Array Variance

Description

The list of methods to do Array Variance are organized into topic(s).

Method

double[]variance(double m[], double[][] o)
variance
int rows = o.length;
int cols = o[0].length;
double[] var = new double[m.length];
Arrays.fill(var, 0.0);
if (rows == 1) {
    return var;
for (double[] row : o) {
...
doublevariance(double[] d, double mean)
Calculates and returns the variance of the given list of double values.
if (d.length <= 1) {
    return 0.0;
double sum = 0.0;
for (int i = 0; i < d.length; i++) {
    sum += Math.pow(d[i] - mean, 2);
return sum / (d.length - 1);
...
doublevariance(double[] data, double meanVal)
variance
return variance(data, meanVal, 0, data.length - 1);
double[]variance(double[][] x, double[] meanVector, boolean isAlongRows)
Returns the variance of rows or columns of matrix x
double[] var = null;
if (x != null && x[0] != null && x[0].length > 0 && meanVector != null) {
    if (isAlongRows) {
        var = new double[x[0].length];
        int j, i;
        for (j = 0; j < x[0].length; j++) {
            for (i = 0; i < x.length; i++)
                var[j] += (x[i][j] - meanVector[j]) * (x[i][j] - meanVector[j]);
...