Here you can find the source of euclideanDistanceNorm(float[] x, float[] y)
public static double euclideanDistanceNorm(float[] x, float[] y)
//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); } }