@Test public void test1(){ int[] v1 = {1,2,3}; int[] v2 = {2,3,1}; Asserts.assertEqualLength(v1, v2); Asserts.assertPositiveValues(v1); Asserts.assertPositiveValues(v2); double res = SpearmanRank.distance(v1, v2); Asserts.assertEquals(res, 0.75); }
public static double distance(int[] v1,int[] v2){ double res = 0; for(int i=0;i<v1.length;i++){ res += Math.pow(v1[i]-v2[i], 2); } return (6*((double)res)/(v1.length*(Math.pow(v1.length, 2)-1)))/2; }
SpearmanRank { public static double distance(int[] v1,int[] v2){ double res = 0; for(int i=0;i<v1.length;i++){ res += Math.pow(v1[i]-v2[i], 2); } return (6*((double)res)/(v1.length*(Math.pow(v1.length, 2)-1)))/2; } }
SpearmanRank { public static double distance(int[] v1,int[] v2){ double res = 0; for(int i=0;i<v1.length;i++){ res += Math.pow(v1[i]-v2[i], 2); } return (6*((double)res)/(v1.length*(Math.pow(v1.length, 2)-1)))/2; }  }
SpearmanRank { public static double distance(int[] v1,int[] v2){ double res = 0; for(int i=0;i<v1.length;i++){ res += Math.pow(v1[i]-v2[i], 2); } return (6*((double)res)/(v1.length*(Math.pow(v1.length, 2)-1)))/2; }  static double distance(int[] v1,int[] v2); }
SpearmanRank { public static double distance(int[] v1,int[] v2){ double res = 0; for(int i=0;i<v1.length;i++){ res += Math.pow(v1[i]-v2[i], 2); } return (6*((double)res)/(v1.length*(Math.pow(v1.length, 2)-1)))/2; }  static double distance(int[] v1,int[] v2);  }