@Test public void test3(){ double[] v1 = new double[]{248.124,321.574,788.14,0.001,459.298}; double[] v2 = new double[]{97.145,78.658,417.0004,4.02,7865.3594}; double res = Motyka.distance(v1, v2); Asserts.assertEquals(res, 0.10235136375463); }
public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertGreaterOrEqualThanValue(v1, 0); Asserts.assertGreaterOrEqualThanValue(v2, 0); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += CommonStats.min(v1[i], v2[i]); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; }
Motyka { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertGreaterOrEqualThanValue(v1, 0); Asserts.assertGreaterOrEqualThanValue(v2, 0); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += CommonStats.min(v1[i], v2[i]); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; } }
Motyka { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertGreaterOrEqualThanValue(v1, 0); Asserts.assertGreaterOrEqualThanValue(v2, 0); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += CommonStats.min(v1[i], v2[i]); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; }  }
Motyka { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertGreaterOrEqualThanValue(v1, 0); Asserts.assertGreaterOrEqualThanValue(v2, 0); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += CommonStats.min(v1[i], v2[i]); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; }  static double distance(double[] v1,double[] v2); }
Motyka { public static double distance(double[] v1,double[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertGreaterOrEqualThanValue(v1, 0); Asserts.assertGreaterOrEqualThanValue(v2, 0); Asserts.assertHasAllZeros(v1); Asserts.assertHasAllZeros(v2); double sumNum = 0; double sumDenom = 0; for(int i=0;i<v1.length;i++){ sumNum += CommonStats.min(v1[i], v2[i]); sumDenom += (v1[i] + v2[i]); } return sumNum/sumDenom; }  static double distance(double[] v1,double[] v2);  }