SokalSneath3 { public static double distance(int[] v1, int[] v2){ Asserts.assertEqualLength(v1, v2); Asserts.assertIsBinary(v1); Asserts.assertIsBinary(v2); int[] matches = CommonStats.processTwoBinaryVectors(v1, v2); return (double)(matches[1]+matches[2])/(double)(matches[0]+matches[3]); }  static double distance(int[] v1, int[] v2);  }
@Test public void test1(){ int[] v1 = new int[]{1,0,1}; int[] v2 = new int[]{1,1,0}; double res = SokalSneath3.distance(v1, v2); Asserts.assertEquals(res, 2); }
@Test public void test2(){ int[] v1 = new int[]{1,1,1,1}; int[] v2 = new int[]{0,1,0,0}; double res = SokalSneath3.distance(v1, v2); Asserts.assertEquals(res, 3); }
@Test public void test3(){ int[] v1 = new int[]{1,0,1,1,0}; int[] v2 = new int[]{1,1,0,1,1}; double res = SokalSneath3.distance(v1, v2); Asserts.assertEquals(res, 1.5); }
@Test public void test4(){ int[] v1 = new int[]{1,0,1,1,0,0}; int[] v2 = new int[]{1,1,0,1,1,1}; double res = SokalSneath3.distance(v1, v2); Asserts.assertEquals(res, 2); }
@Test public void test5(){ int[] v1 = new int[]{1,0,1,1,0,0,1}; int[] v2 = new int[]{1,1,0,1,1,1,1}; double res = SokalSneath3.distance(v1, v2); Asserts.assertEquals(res, 1.333333); }
@Test public void test6(){ int[] v1 = new int[]{1,0,1,1,0,0,1,1}; int[] v2 = new int[]{1,1,0,1,1,1,1,0}; double res = SokalSneath3.distance(v1, v2); Asserts.assertEquals(res, 1.6666666); }
@Test public void test7(){ int[] v1 = new int[]{1,0,1,1,0,0,1,1,1}; int[] v2 = new int[]{1,1,0,1,1,1,1,0,1}; double res = SokalSneath3.distance(v1, v2); Asserts.assertEquals(res, 1.25); }
@Test public void test8(){ int[] v1 = new int[]{1,0,1,1,0,0,1,1,1,1}; int[] v2 = new int[]{1,1,0,1,1,1,1,0,1,0}; double res = SokalSneath3.distance(v1, v2); Asserts.assertEquals(res, 1.5); }