Java Utililty Methods Variance

List of utility methods to do Variance

Description

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

Method

floatvariance(float[] v, float average)
variance
if (v.length == 0)
    return 0.0f;
float sum = 0.0f;
for (int k = 0; k < v.length; ++k)
    sum += (v[k] - average) * (v[k] - average);
return sum / v.length;
Doublevariance(Integer[] values)
variance
Double mean = mean(values);
if (mean == null) {
    return null;
double tmp = 0;
double numIntegers = 0;
for (Integer i : values) {
    if (i == null) {
...
double[]variances(double[] data)
variances
double sum = 0;
double sumsquare = 0;
int len = data.length;
double mean = 0;
double[] variances = new double[len];
for (int i = 0; i < len; ++i) {
    sum += data[i];
    sumsquare += data[i] * data[i];
...
doublevarianceTwo(final double[] values)
variance Two
final long n = values.length;
final long n1 = values.length - 1;
final double sumOfSquares = sum(pow(values, 2)) / n1;
final double squareOfSum = Math.pow(sum(values), 2) / (n * n1);
return sumOfSquares - squareOfSum;