All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.chen0040.svmext.utils.Variance Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
package com.github.chen0040.svmext.utils;

/**
 * Created by memeanalytics on 14/8/15.
 */
public class Variance {
    public static double apply(double[] values, double mu) {
        int length = values.length;
        if(length <= 1) return Double.NaN;

        double num1;
        double sum = 0;
        for(int i=0; i < length; ++i){
            num1 = (values[i] - mu);
            sum += num1 * num1;
        }

        return sum / (length - 1);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy