Java Euclidean Distance euclidean(double[] xvalues, double[] yvalues, int[] include)

Here you can find the source of euclidean(double[] xvalues, double[] yvalues, int[] include)

Description

Returns the euclidean distance between xvalues and yvalues for those include values that are non-zero.

License

Open Source License

Declaration

public static double euclidean(double[] xvalues, double[] yvalues, int[] include) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from   w w  w. ja  v a  2s  .  co  m
     * Returns the euclidean distance between xvalues and yvalues for those include values
     * that are non-zero.
     */
    public static double euclidean(double[] xvalues, double[] yvalues, int[] include) {
        double ddiff;
        double ddist;
        double dsumsq = 0;

        for (int nindex = 0; nindex < include.length; nindex++) {
            if (include[nindex] != 0) {
                ddiff = (xvalues[nindex] - yvalues[nindex]);
                dsumsq += ddiff * ddiff;
            }
        }

        ddist = Math.sqrt(dsumsq);

        return ddist;
    }
}

Related

  1. euclidean(double[] _a, double[] _b)
  2. euclidean(double[] a, double[] b)
  3. euclidean(Double[] a, Double[] b)
  4. euclidean(double[] features1, double[] features2)
  5. euclidean(double[] x1, double[] x2)
  6. euclidean_distance(double[] vec1, double[] vec2)
  7. euclideanDist(double[] ePointOne, double[] ePoint2)
  8. euclideanDist(final double[] vec1, final double[] vec2, int n)
  9. euclideanDist(float[] v1, float[] v2)