@Test public void testTest() { logger.info("test"); FlatDataCollection flatDataCollection = new FlatDataCollection(Arrays.asList(new Object[]{33.4, 33.3, 31.0, 31.4, 33.5, 34.4, 33.7, 36.2, 34.9, 37.0})); String cdfMethod = "normalDistribution"; double aLevel = 0.3; boolean expResult = false; boolean result = Lilliefors.test(flatDataCollection, cdfMethod, aLevel); assertEquals(expResult, result); }
public static boolean test(FlatDataCollection flatDataCollection, String cdfMethod, double aLevel) { double[] doubleArray = flatDataCollection.stream().filter(x -> x!=null).mapToDouble(TypeInference::toDouble).toArray(); int n = doubleArray.length; if(n<=0) { throw new IllegalArgumentException("The provided collection can't be empty."); } Arrays.sort(doubleArray); double observedProbabilityIminus1=0; double maxDelta=0; int rank=1; try { Method method; method = Lilliefors.class.getMethod(cdfMethod + "GetParams", FlatDataCollection.class); AssociativeArray params = (AssociativeArray)method.invoke(null, flatDataCollection); method = Lilliefors.class.getMethod(cdfMethod, Double.class, AssociativeArray.class); for(int i=0;i<doubleArray.length;++i) { double x = doubleArray[i]; double observedProbabilityI=(double)rank/n; Object methodResult = method.invoke(null, x, params); double expectedProbabilityI = TypeInference.toDouble(methodResult); double delta=Math.max(Math.abs(expectedProbabilityI-observedProbabilityI),Math.abs(expectedProbabilityI-observedProbabilityIminus1)); if(delta>=maxDelta) { maxDelta=delta; } observedProbabilityIminus1=observedProbabilityI; ++rank; } boolean rejectH0=checkCriticalValue(maxDelta, n, aLevel); return rejectH0; } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } }
Lilliefors { public static boolean test(FlatDataCollection flatDataCollection, String cdfMethod, double aLevel) { double[] doubleArray = flatDataCollection.stream().filter(x -> x!=null).mapToDouble(TypeInference::toDouble).toArray(); int n = doubleArray.length; if(n<=0) { throw new IllegalArgumentException("The provided collection can't be empty."); } Arrays.sort(doubleArray); double observedProbabilityIminus1=0; double maxDelta=0; int rank=1; try { Method method; method = Lilliefors.class.getMethod(cdfMethod + "GetParams", FlatDataCollection.class); AssociativeArray params = (AssociativeArray)method.invoke(null, flatDataCollection); method = Lilliefors.class.getMethod(cdfMethod, Double.class, AssociativeArray.class); for(int i=0;i<doubleArray.length;++i) { double x = doubleArray[i]; double observedProbabilityI=(double)rank/n; Object methodResult = method.invoke(null, x, params); double expectedProbabilityI = TypeInference.toDouble(methodResult); double delta=Math.max(Math.abs(expectedProbabilityI-observedProbabilityI),Math.abs(expectedProbabilityI-observedProbabilityIminus1)); if(delta>=maxDelta) { maxDelta=delta; } observedProbabilityIminus1=observedProbabilityI; ++rank; } boolean rejectH0=checkCriticalValue(maxDelta, n, aLevel); return rejectH0; } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } } }
Lilliefors { public static boolean test(FlatDataCollection flatDataCollection, String cdfMethod, double aLevel) { double[] doubleArray = flatDataCollection.stream().filter(x -> x!=null).mapToDouble(TypeInference::toDouble).toArray(); int n = doubleArray.length; if(n<=0) { throw new IllegalArgumentException("The provided collection can't be empty."); } Arrays.sort(doubleArray); double observedProbabilityIminus1=0; double maxDelta=0; int rank=1; try { Method method; method = Lilliefors.class.getMethod(cdfMethod + "GetParams", FlatDataCollection.class); AssociativeArray params = (AssociativeArray)method.invoke(null, flatDataCollection); method = Lilliefors.class.getMethod(cdfMethod, Double.class, AssociativeArray.class); for(int i=0;i<doubleArray.length;++i) { double x = doubleArray[i]; double observedProbabilityI=(double)rank/n; Object methodResult = method.invoke(null, x, params); double expectedProbabilityI = TypeInference.toDouble(methodResult); double delta=Math.max(Math.abs(expectedProbabilityI-observedProbabilityI),Math.abs(expectedProbabilityI-observedProbabilityIminus1)); if(delta>=maxDelta) { maxDelta=delta; } observedProbabilityIminus1=observedProbabilityI; ++rank; } boolean rejectH0=checkCriticalValue(maxDelta, n, aLevel); return rejectH0; } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } }  }
Lilliefors { public static boolean test(FlatDataCollection flatDataCollection, String cdfMethod, double aLevel) { double[] doubleArray = flatDataCollection.stream().filter(x -> x!=null).mapToDouble(TypeInference::toDouble).toArray(); int n = doubleArray.length; if(n<=0) { throw new IllegalArgumentException("The provided collection can't be empty."); } Arrays.sort(doubleArray); double observedProbabilityIminus1=0; double maxDelta=0; int rank=1; try { Method method; method = Lilliefors.class.getMethod(cdfMethod + "GetParams", FlatDataCollection.class); AssociativeArray params = (AssociativeArray)method.invoke(null, flatDataCollection); method = Lilliefors.class.getMethod(cdfMethod, Double.class, AssociativeArray.class); for(int i=0;i<doubleArray.length;++i) { double x = doubleArray[i]; double observedProbabilityI=(double)rank/n; Object methodResult = method.invoke(null, x, params); double expectedProbabilityI = TypeInference.toDouble(methodResult); double delta=Math.max(Math.abs(expectedProbabilityI-observedProbabilityI),Math.abs(expectedProbabilityI-observedProbabilityIminus1)); if(delta>=maxDelta) { maxDelta=delta; } observedProbabilityIminus1=observedProbabilityI; ++rank; } boolean rejectH0=checkCriticalValue(maxDelta, n, aLevel); return rejectH0; } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } }  static boolean test(FlatDataCollection flatDataCollection, String cdfMethod, double aLevel); static AssociativeArray normalDistributionGetParams(FlatDataCollection flatDataCollection); static double normalDistribution(Double x, AssociativeArray params); }
Lilliefors { public static boolean test(FlatDataCollection flatDataCollection, String cdfMethod, double aLevel) { double[] doubleArray = flatDataCollection.stream().filter(x -> x!=null).mapToDouble(TypeInference::toDouble).toArray(); int n = doubleArray.length; if(n<=0) { throw new IllegalArgumentException("The provided collection can't be empty."); } Arrays.sort(doubleArray); double observedProbabilityIminus1=0; double maxDelta=0; int rank=1; try { Method method; method = Lilliefors.class.getMethod(cdfMethod + "GetParams", FlatDataCollection.class); AssociativeArray params = (AssociativeArray)method.invoke(null, flatDataCollection); method = Lilliefors.class.getMethod(cdfMethod, Double.class, AssociativeArray.class); for(int i=0;i<doubleArray.length;++i) { double x = doubleArray[i]; double observedProbabilityI=(double)rank/n; Object methodResult = method.invoke(null, x, params); double expectedProbabilityI = TypeInference.toDouble(methodResult); double delta=Math.max(Math.abs(expectedProbabilityI-observedProbabilityI),Math.abs(expectedProbabilityI-observedProbabilityIminus1)); if(delta>=maxDelta) { maxDelta=delta; } observedProbabilityIminus1=observedProbabilityI; ++rank; } boolean rejectH0=checkCriticalValue(maxDelta, n, aLevel); return rejectH0; } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { throw new IllegalArgumentException(ex); } }  static boolean test(FlatDataCollection flatDataCollection, String cdfMethod, double aLevel); static AssociativeArray normalDistributionGetParams(FlatDataCollection flatDataCollection); static double normalDistribution(Double x, AssociativeArray params);  }