Here you can find the source of distance(double[] a, double[] b)
public static double distance(double[] a, double[] b)
//package com.java2s; //License from project: Open Source License public class Main { /**/* w ww . j av a 2s . co m*/ * Calculates the distance between two points represented by (n-dimensional) vectors. */ public static double distance(double[] a, double[] b) { double dist = 0; for (int i = 0; i < a.length; i++) { double d = a[i] - b[i]; dist += d * d; } return Math.sqrt(dist); } }