Example usage for org.apache.commons.math.stat StatUtils sumSq

List of usage examples for org.apache.commons.math.stat StatUtils sumSq

Introduction

In this page you can find the example usage for org.apache.commons.math.stat StatUtils sumSq.

Prototype

public static double sumSq(final double[] values) 

Source Link

Document

Returns the sum of the squares of the entries in the input array, or Double.NaN if the array is empty.

Usage

From source file:es.udc.gii.common.eaf.util.EAFMath.java

public static double distance(double[] pI, double[] pJ) {
    double[] auxArray = new double[pI.length];

    for (int i = 0; i < pI.length; i++) {
        auxArray[i] = pI[i] - pJ[i];/*from ww  w  .j  ava  2s.co  m*/
    }
    double sumSq = StatUtils.sumSq(auxArray);

    return (sumSq == 0.0 ? 0.0 : Math.sqrt(sumSq));
}

From source file:es.udc.gii.common.eaf.util.EAFMath.java

public static double perpendicularDistance(double[] pI, double[] pJ) {

    double pJmodule = (StatUtils.sumSq(pJ) != 0.0 ? Math.sqrt(StatUtils.sumSq(pJ)) : 0.0);

    return (pJmodule != 0.0 ? innerProduct(pI, pJ) / pJmodule : 0.0);

}

From source file:es.udc.gii.common.eaf.util.EAFMath.java

public static double distance(List<Double> pI, List<Double> pJ) {
    double[] auxArray = new double[pI.size()];

    for (int i = 0; i < pI.size(); i++) {
        auxArray[i] = pI.get(i) - pJ.get(i);
    }//from  w ww  .jav  a  2 s .c om

    double sumSq = StatUtils.sumSq(auxArray);

    return (sumSq == 0.0 ? 0.0 : Math.sqrt(sumSq));
}

From source file:es.udc.gii.common.eaf.benchmark.constrained_real_param.g03.G03ConstraintFunction_h1.java

@Override
public double evaluate(double[] values) {

    double[] norm_values;

    norm_values = G03Function.normalize(values);

    return StatUtils.sumSq(norm_values) - 1.0;

}

From source file:es.udc.gii.common.eaf.util.EAFMath.java

public static double perpendicularDistance(List<Double> pI, List<Double> pJ) {

    double[] pJarray = new double[pJ.size()];

    for (int i = 0; i < pJ.size(); i++) {
        pJarray[i] = pJ.get(i);/* w w w  . j  a  v  a 2 s  .  c om*/
    }

    double pJmodule = (StatUtils.sumSq(pJarray) != 0.0 ? Math.sqrt(StatUtils.sumSq(pJarray)) : 0.0);

    return (pJmodule != 0.0 ? innerProduct(pI, pJ) / pJmodule : 0.0);

}