@Test public void testTest() { logger.info("test"); TransposeDataList transposeDataList = new TransposeDataList(); transposeDataList.put(0, new FlatDataList(Arrays.asList(new Object[]{15.9,15.9,16.0,16.1,16.1,16.2,16.3,16.5,15.5,15.7,15.8}))); transposeDataList.put(1, new FlatDataList(Arrays.asList(new Object[]{15.1,15.2,15.4,15.6,16.6,16.8,16.9,15.7,16.0,16.3,16.4}))); boolean expResult = false; boolean is_twoTailed = true; double aLevel = 0.05; boolean result = KolmogorovSmirnovIndependentSamples.test(transposeDataList, is_twoTailed, aLevel); assertEquals(expResult, result); }
public static boolean test(TransposeDataList transposeDataList, boolean is_twoTailed, double aLevel) { int k=transposeDataList.size(); if(k!=2) { throw new IllegalArgumentException("The collection must contain observations from 2 groups."); } Object[] keys = transposeDataList.keySet().toArray(); Set<Double> allUniqueValues = new TreeSet<>(); for(int j=0;j<k;++j) { Iterator<Double> it = transposeDataList.get(keys[j]).iteratorDouble(); while(it.hasNext()) { allUniqueValues.add(it.next()); } } DataTable2D distributionAndValue2Probability = new DataTable2D(); for(int j=0;j<k;++j) { Object keyj = keys[j]; int nj=transposeDataList.get(keyj).size(); if(nj<=0) { throw new IllegalArgumentException("The number of observations in each group but be larger than 0."); } int rank = 1; for(Double value : allUniqueValues) { Object objValue = value; if(!transposeDataList.get(keyj).contains(objValue)) { distributionAndValue2Probability.put2d(keyj, objValue, (rank-1.0)/nj); continue; } if(distributionAndValue2Probability.get2d(keyj, objValue)==null) { distributionAndValue2Probability.put2d(keyj, objValue, (double)rank/nj); } ++rank; } } double maxDelta=0.0; for(Object key : distributionAndValue2Probability.get(keys[0]).keySet()) { double v1 = distributionAndValue2Probability.get(keys[0]).getDouble(key); double v2 = distributionAndValue2Probability.get(keys[1]).getDouble(key); double delta=Math.abs(v2-v1); if(delta>maxDelta) { maxDelta=delta; } } int n1 = transposeDataList.get(keys[0]).size(); int n2 = transposeDataList.get(keys[1]).size(); boolean rejectH0 = checkCriticalValue(maxDelta, is_twoTailed, n1, n2, aLevel); return rejectH0; }
KolmogorovSmirnovIndependentSamples { public static boolean test(TransposeDataList transposeDataList, boolean is_twoTailed, double aLevel) { int k=transposeDataList.size(); if(k!=2) { throw new IllegalArgumentException("The collection must contain observations from 2 groups."); } Object[] keys = transposeDataList.keySet().toArray(); Set<Double> allUniqueValues = new TreeSet<>(); for(int j=0;j<k;++j) { Iterator<Double> it = transposeDataList.get(keys[j]).iteratorDouble(); while(it.hasNext()) { allUniqueValues.add(it.next()); } } DataTable2D distributionAndValue2Probability = new DataTable2D(); for(int j=0;j<k;++j) { Object keyj = keys[j]; int nj=transposeDataList.get(keyj).size(); if(nj<=0) { throw new IllegalArgumentException("The number of observations in each group but be larger than 0."); } int rank = 1; for(Double value : allUniqueValues) { Object objValue = value; if(!transposeDataList.get(keyj).contains(objValue)) { distributionAndValue2Probability.put2d(keyj, objValue, (rank-1.0)/nj); continue; } if(distributionAndValue2Probability.get2d(keyj, objValue)==null) { distributionAndValue2Probability.put2d(keyj, objValue, (double)rank/nj); } ++rank; } } double maxDelta=0.0; for(Object key : distributionAndValue2Probability.get(keys[0]).keySet()) { double v1 = distributionAndValue2Probability.get(keys[0]).getDouble(key); double v2 = distributionAndValue2Probability.get(keys[1]).getDouble(key); double delta=Math.abs(v2-v1); if(delta>maxDelta) { maxDelta=delta; } } int n1 = transposeDataList.get(keys[0]).size(); int n2 = transposeDataList.get(keys[1]).size(); boolean rejectH0 = checkCriticalValue(maxDelta, is_twoTailed, n1, n2, aLevel); return rejectH0; } }
KolmogorovSmirnovIndependentSamples { public static boolean test(TransposeDataList transposeDataList, boolean is_twoTailed, double aLevel) { int k=transposeDataList.size(); if(k!=2) { throw new IllegalArgumentException("The collection must contain observations from 2 groups."); } Object[] keys = transposeDataList.keySet().toArray(); Set<Double> allUniqueValues = new TreeSet<>(); for(int j=0;j<k;++j) { Iterator<Double> it = transposeDataList.get(keys[j]).iteratorDouble(); while(it.hasNext()) { allUniqueValues.add(it.next()); } } DataTable2D distributionAndValue2Probability = new DataTable2D(); for(int j=0;j<k;++j) { Object keyj = keys[j]; int nj=transposeDataList.get(keyj).size(); if(nj<=0) { throw new IllegalArgumentException("The number of observations in each group but be larger than 0."); } int rank = 1; for(Double value : allUniqueValues) { Object objValue = value; if(!transposeDataList.get(keyj).contains(objValue)) { distributionAndValue2Probability.put2d(keyj, objValue, (rank-1.0)/nj); continue; } if(distributionAndValue2Probability.get2d(keyj, objValue)==null) { distributionAndValue2Probability.put2d(keyj, objValue, (double)rank/nj); } ++rank; } } double maxDelta=0.0; for(Object key : distributionAndValue2Probability.get(keys[0]).keySet()) { double v1 = distributionAndValue2Probability.get(keys[0]).getDouble(key); double v2 = distributionAndValue2Probability.get(keys[1]).getDouble(key); double delta=Math.abs(v2-v1); if(delta>maxDelta) { maxDelta=delta; } } int n1 = transposeDataList.get(keys[0]).size(); int n2 = transposeDataList.get(keys[1]).size(); boolean rejectH0 = checkCriticalValue(maxDelta, is_twoTailed, n1, n2, aLevel); return rejectH0; }  }
KolmogorovSmirnovIndependentSamples { public static boolean test(TransposeDataList transposeDataList, boolean is_twoTailed, double aLevel) { int k=transposeDataList.size(); if(k!=2) { throw new IllegalArgumentException("The collection must contain observations from 2 groups."); } Object[] keys = transposeDataList.keySet().toArray(); Set<Double> allUniqueValues = new TreeSet<>(); for(int j=0;j<k;++j) { Iterator<Double> it = transposeDataList.get(keys[j]).iteratorDouble(); while(it.hasNext()) { allUniqueValues.add(it.next()); } } DataTable2D distributionAndValue2Probability = new DataTable2D(); for(int j=0;j<k;++j) { Object keyj = keys[j]; int nj=transposeDataList.get(keyj).size(); if(nj<=0) { throw new IllegalArgumentException("The number of observations in each group but be larger than 0."); } int rank = 1; for(Double value : allUniqueValues) { Object objValue = value; if(!transposeDataList.get(keyj).contains(objValue)) { distributionAndValue2Probability.put2d(keyj, objValue, (rank-1.0)/nj); continue; } if(distributionAndValue2Probability.get2d(keyj, objValue)==null) { distributionAndValue2Probability.put2d(keyj, objValue, (double)rank/nj); } ++rank; } } double maxDelta=0.0; for(Object key : distributionAndValue2Probability.get(keys[0]).keySet()) { double v1 = distributionAndValue2Probability.get(keys[0]).getDouble(key); double v2 = distributionAndValue2Probability.get(keys[1]).getDouble(key); double delta=Math.abs(v2-v1); if(delta>maxDelta) { maxDelta=delta; } } int n1 = transposeDataList.get(keys[0]).size(); int n2 = transposeDataList.get(keys[1]).size(); boolean rejectH0 = checkCriticalValue(maxDelta, is_twoTailed, n1, n2, aLevel); return rejectH0; }  static boolean test(TransposeDataList transposeDataList, boolean is_twoTailed, double aLevel); }
KolmogorovSmirnovIndependentSamples { public static boolean test(TransposeDataList transposeDataList, boolean is_twoTailed, double aLevel) { int k=transposeDataList.size(); if(k!=2) { throw new IllegalArgumentException("The collection must contain observations from 2 groups."); } Object[] keys = transposeDataList.keySet().toArray(); Set<Double> allUniqueValues = new TreeSet<>(); for(int j=0;j<k;++j) { Iterator<Double> it = transposeDataList.get(keys[j]).iteratorDouble(); while(it.hasNext()) { allUniqueValues.add(it.next()); } } DataTable2D distributionAndValue2Probability = new DataTable2D(); for(int j=0;j<k;++j) { Object keyj = keys[j]; int nj=transposeDataList.get(keyj).size(); if(nj<=0) { throw new IllegalArgumentException("The number of observations in each group but be larger than 0."); } int rank = 1; for(Double value : allUniqueValues) { Object objValue = value; if(!transposeDataList.get(keyj).contains(objValue)) { distributionAndValue2Probability.put2d(keyj, objValue, (rank-1.0)/nj); continue; } if(distributionAndValue2Probability.get2d(keyj, objValue)==null) { distributionAndValue2Probability.put2d(keyj, objValue, (double)rank/nj); } ++rank; } } double maxDelta=0.0; for(Object key : distributionAndValue2Probability.get(keys[0]).keySet()) { double v1 = distributionAndValue2Probability.get(keys[0]).getDouble(key); double v2 = distributionAndValue2Probability.get(keys[1]).getDouble(key); double delta=Math.abs(v2-v1); if(delta>maxDelta) { maxDelta=delta; } } int n1 = transposeDataList.get(keys[0]).size(); int n2 = transposeDataList.get(keys[1]).size(); boolean rejectH0 = checkCriticalValue(maxDelta, is_twoTailed, n1, n2, aLevel); return rejectH0; }  static boolean test(TransposeDataList transposeDataList, boolean is_twoTailed, double aLevel);  }