@Test public void test4(){ double[] v1 = new double[]{1, 5, 8, 4}; double[] v2 = new double[]{3, 10, 9, 6}; Asserts.assertEqualLength(v1, v2); double res = Canberra.distance(v1, v2); Asserts.assertEquals(res, 1.092156863); }
public static double distance(double[] v1,double[] v2){ double sum = 0; for(int i=0;i<v1.length;i++){ sum += CommonStats.abs(v1[i]-v2[i])/(CommonStats.abs(v1[i])+CommonStats.abs(v2[i])); } return sum; }
Canberra { public static double distance(double[] v1,double[] v2){ double sum = 0; for(int i=0;i<v1.length;i++){ sum += CommonStats.abs(v1[i]-v2[i])/(CommonStats.abs(v1[i])+CommonStats.abs(v2[i])); } return sum; } }
Canberra { public static double distance(double[] v1,double[] v2){ double sum = 0; for(int i=0;i<v1.length;i++){ sum += CommonStats.abs(v1[i]-v2[i])/(CommonStats.abs(v1[i])+CommonStats.abs(v2[i])); } return sum; }  }
Canberra { public static double distance(double[] v1,double[] v2){ double sum = 0; for(int i=0;i<v1.length;i++){ sum += CommonStats.abs(v1[i]-v2[i])/(CommonStats.abs(v1[i])+CommonStats.abs(v2[i])); } return sum; }  static double distance(double[] v1,double[] v2); }
Canberra { public static double distance(double[] v1,double[] v2){ double sum = 0; for(int i=0;i<v1.length;i++){ sum += CommonStats.abs(v1[i]-v2[i])/(CommonStats.abs(v1[i])+CommonStats.abs(v2[i])); } return sum; }  static double distance(double[] v1,double[] v2);  }