Here you can find the source of euclidean(Double[] a, Double[] b)
Parameter | Description |
---|---|
a | a parameter |
b | a parameter |
public static double euclidean(Double[] a, Double[] b)
//package com.java2s; //License from project: Open Source License public class Main { /**// ww w . j a v a2 s. co m * Compute the Euclidean distance between two arrays of the same size. * @param a * @param b * @return the Euclidean distance */ public static double euclidean(Double[] a, Double[] b) { double sum = 0.0; for (int i = 0; i < a.length; i++) { double diff = a[i] - b[i]; sum += diff * diff; } return Math.sqrt(sum); } }