Java Euclidean Distance euclideanDistanceNorm(float[] x, float[] y)

Here you can find the source of euclideanDistanceNorm(float[] x, float[] y)

Description

euclidean Distance Norm

License

Open Source License

Declaration

public static double euclideanDistanceNorm(float[] x, float[] y) 

Method Source Code

//package com.java2s;
/***********************************************************************
 *
 * This software is Copyright (C) 2013 Fabio Corubolo - corubolo@gmail.com - and Meriem Bendis
 * The University of Liverpool//from   ww w . ja  v a  2  s  .c  om
 *
 *
 * BranchingStoryGenerator is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * BranchingStoryGenerator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JavaFF.  If not, see <http://www.gnu.org/licenses/>.
 *
 ************************************************************************/

public class Main {
    public static double euclideanDistanceNorm(float[] x, float[] y) {
        double sumXY2 = 0.0;
        for (int i = 0, n = x.length; i < n; i++) {
            if (Float.isNaN(x[i]) || Float.isNaN(y[i]))
                sumXY2 += 1;
            else
                sumXY2 += Math.pow(x[i] - y[i], 2);
        }
        return Math.sqrt(sumXY2) / Math.sqrt(x.length);
    }
}

Related

  1. euclideanDistance(double[] vector)
  2. euclideanDistance(double[] vector1, double[] vector2)
  3. euclideanDistance(float[] points, int p1, int p2, boolean isDisp, double width, double height)
  4. euclideanDistance(int i0, int j0, int i1, int j1)
  5. euclideanDistance(int startX, int startY, int startZ, int endX, int endY, int endZ)
  6. euclideanDistanceSq2D(float x1, float y1, float x2, float y2)