@Test public void testTestAutocorrelation() { logger.info("testAutocorrelation"); FlatDataCollection pkList = new FlatDataCollection(Arrays.asList(new Object[]{0.810,0.631,0.469,0.349})); int n = 100; double aLevel = 0.05; boolean expResult = true; boolean result = LjungBox.testAutocorrelation(pkList, n, aLevel); assertEquals(expResult, result); }
public static boolean testAutocorrelation(FlatDataCollection pkList, int n, double aLevel) { int h=pkList.size(); if(n<=h) { throw new IllegalArgumentException("The n must be larger than the size of pkList."); } double Q=0; int k=1; Iterator<Double> it = pkList.iteratorDouble(); while(it.hasNext()) { Double pkValue = it.next(); Q+=(pkValue*pkValue)/(n-k); ++k; } Q*=n*(n+2); boolean rejectH0=checkCriticalValue(Q, h, aLevel); return rejectH0; }
LjungBox { public static boolean testAutocorrelation(FlatDataCollection pkList, int n, double aLevel) { int h=pkList.size(); if(n<=h) { throw new IllegalArgumentException("The n must be larger than the size of pkList."); } double Q=0; int k=1; Iterator<Double> it = pkList.iteratorDouble(); while(it.hasNext()) { Double pkValue = it.next(); Q+=(pkValue*pkValue)/(n-k); ++k; } Q*=n*(n+2); boolean rejectH0=checkCriticalValue(Q, h, aLevel); return rejectH0; } }
LjungBox { public static boolean testAutocorrelation(FlatDataCollection pkList, int n, double aLevel) { int h=pkList.size(); if(n<=h) { throw new IllegalArgumentException("The n must be larger than the size of pkList."); } double Q=0; int k=1; Iterator<Double> it = pkList.iteratorDouble(); while(it.hasNext()) { Double pkValue = it.next(); Q+=(pkValue*pkValue)/(n-k); ++k; } Q*=n*(n+2); boolean rejectH0=checkCriticalValue(Q, h, aLevel); return rejectH0; }  }
LjungBox { public static boolean testAutocorrelation(FlatDataCollection pkList, int n, double aLevel) { int h=pkList.size(); if(n<=h) { throw new IllegalArgumentException("The n must be larger than the size of pkList."); } double Q=0; int k=1; Iterator<Double> it = pkList.iteratorDouble(); while(it.hasNext()) { Double pkValue = it.next(); Q+=(pkValue*pkValue)/(n-k); ++k; } Q*=n*(n+2); boolean rejectH0=checkCriticalValue(Q, h, aLevel); return rejectH0; }  static boolean testAutocorrelation(FlatDataCollection pkList, int n, double aLevel); }
LjungBox { public static boolean testAutocorrelation(FlatDataCollection pkList, int n, double aLevel) { int h=pkList.size(); if(n<=h) { throw new IllegalArgumentException("The n must be larger than the size of pkList."); } double Q=0; int k=1; Iterator<Double> it = pkList.iteratorDouble(); while(it.hasNext()) { Double pkValue = it.next(); Q+=(pkValue*pkValue)/(n-k); ++k; } Q*=n*(n+2); boolean rejectH0=checkCriticalValue(Q, h, aLevel); return rejectH0; }  static boolean testAutocorrelation(FlatDataCollection pkList, int n, double aLevel);  }