@Test public void test2(){ double[] v1 = new double[]{8,32,7,1,45}; double[] v2 = new double[]{97,78,41,4,78}; double res = Roberts.distance(v1, v2); Asserts.assertEquals(res, 0.34320884745626); }
public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertPositiveValues(v1); Asserts.assertPositiveValues(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += (v1[i] + v2[i])*(CommonStats.min(v1[i], v2[i])/CommonStats.max(v1[i], v2[i])); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; }
Roberts { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertPositiveValues(v1); Asserts.assertPositiveValues(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += (v1[i] + v2[i])*(CommonStats.min(v1[i], v2[i])/CommonStats.max(v1[i], v2[i])); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; } }
Roberts { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertPositiveValues(v1); Asserts.assertPositiveValues(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += (v1[i] + v2[i])*(CommonStats.min(v1[i], v2[i])/CommonStats.max(v1[i], v2[i])); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; }  }
Roberts { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertPositiveValues(v1); Asserts.assertPositiveValues(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += (v1[i] + v2[i])*(CommonStats.min(v1[i], v2[i])/CommonStats.max(v1[i], v2[i])); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; }  static double distance(double[] v1,double[] v2); }
Roberts { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertPositiveValues(v1); Asserts.assertPositiveValues(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += (v1[i] + v2[i])*(CommonStats.min(v1[i], v2[i])/CommonStats.max(v1[i], v2[i])); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; }  static double distance(double[] v1,double[] v2);  }