src/main/java/eu/digitisation/math/Arrays.java
public static double cov(int[] X, int[] Y) {
        int len = Math.min(X.length, Y.length);
        double sum = 0;  // double safer against overflows

        for (int n = 0; n < len; ++n) {
            sum += X[n] * (double) Y[n];
        }

        return sum / len - average(X) * average(Y);
    }
/**
     * @param X array of int
     * @param Y another array of int
     * @return the covariance of two variables X and Y are expected to have same
     * length
     */
@param X array of int
@param Y another array of int
@return the covariance of two variables X and Y are expected to have same
length
@param X array of int @param Y another array of int @return the covariance of two variables X and Y are expected to have same length
public static double cov(int[] X, int[] Y) {
        int len = Math.min(X.length, Y.length);
        double sum = 0;  
        for (int n = 0; n < len; ++n) {
            sum += X[n] * (double) Y[n];
        }
        return sum / len - average(X) * average(Y);
    }
public static double cov ( int [ ] X , int [ ] Y ) { int len = Math . min ( X . length , Y . length ) ; double sum = 0 ; for ( int n = 0 ; n < len ; ++ n ) { sum += X [ n ] * ( double ) Y [ n ] ; } return sum / len - average ( X ) * average ( Y ) ; }
@param X array of int
 @param Y another array of int
 @return the covariance of two variables X and Y are expected to have same
 length
@param X array of int @param Y another array of int @return the covariance of two variables X and Y are expected to have same length
// double safer against overflows