@Test public void testMakeHendersonFilter() { for (int i = 1; i < 100; i += 2) { SymmetricFilter filter = TrendCycleFilterFactory.makeHendersonFilter(i); DataBlock w = new DataBlock(filter.getWeights()); assertTrue(Math.abs(w.sum() - 1) < 1e-9); } }
public static SymmetricFilter makeHendersonFilter(int length) { if (length % 2 == 0) throw new LinearFilterException("Invalid length for Henderson filter. Should be odd"); int m = length / 2; double[] c = new double[m + 1]; int n = m + 2; double n2 = n * n; for (int i = 0; i < m + 1; i++) { double ii = (i - m) * (i - m); double up = 315 * (n2 - n * 2 + 1 - (ii)); up *= n2 - ii; up *= n2 + n * 2 + 1 - ii; up *= n2 * 3 - 16 - ii * 11; double down = n * 8; down *= n2 - 1; down *= n2 * 4 - 1; down *= n2 * 4 - 9; down *= n2 * 4 - 25; c[m - i] = up / down; } return SymmetricFilter.of(c); }
TrendCycleFilterFactory { public static SymmetricFilter makeHendersonFilter(int length) { if (length % 2 == 0) throw new LinearFilterException("Invalid length for Henderson filter. Should be odd"); int m = length / 2; double[] c = new double[m + 1]; int n = m + 2; double n2 = n * n; for (int i = 0; i < m + 1; i++) { double ii = (i - m) * (i - m); double up = 315 * (n2 - n * 2 + 1 - (ii)); up *= n2 - ii; up *= n2 + n * 2 + 1 - ii; up *= n2 * 3 - 16 - ii * 11; double down = n * 8; down *= n2 - 1; down *= n2 * 4 - 1; down *= n2 * 4 - 9; down *= n2 * 4 - 25; c[m - i] = up / down; } return SymmetricFilter.of(c); } }
TrendCycleFilterFactory { public static SymmetricFilter makeHendersonFilter(int length) { if (length % 2 == 0) throw new LinearFilterException("Invalid length for Henderson filter. Should be odd"); int m = length / 2; double[] c = new double[m + 1]; int n = m + 2; double n2 = n * n; for (int i = 0; i < m + 1; i++) { double ii = (i - m) * (i - m); double up = 315 * (n2 - n * 2 + 1 - (ii)); up *= n2 - ii; up *= n2 + n * 2 + 1 - ii; up *= n2 * 3 - 16 - ii * 11; double down = n * 8; down *= n2 - 1; down *= n2 * 4 - 1; down *= n2 * 4 - 9; down *= n2 * 4 - 25; c[m - i] = up / down; } return SymmetricFilter.of(c); } private  TrendCycleFilterFactory(); }
TrendCycleFilterFactory { public static SymmetricFilter makeHendersonFilter(int length) { if (length % 2 == 0) throw new LinearFilterException("Invalid length for Henderson filter. Should be odd"); int m = length / 2; double[] c = new double[m + 1]; int n = m + 2; double n2 = n * n; for (int i = 0; i < m + 1; i++) { double ii = (i - m) * (i - m); double up = 315 * (n2 - n * 2 + 1 - (ii)); up *= n2 - ii; up *= n2 + n * 2 + 1 - ii; up *= n2 * 3 - 16 - ii * 11; double down = n * 8; down *= n2 - 1; down *= n2 * 4 - 1; down *= n2 * 4 - 9; down *= n2 * 4 - 25; c[m - i] = up / down; } return SymmetricFilter.of(c); } private  TrendCycleFilterFactory(); static SymmetricFilter defaultHendersonFilterForFrequency(
	    final int frequency); static SymmetricFilter makeHendersonFilter(int length); static SymmetricFilter makeTrendFilter(final int frequency); }
TrendCycleFilterFactory { public static SymmetricFilter makeHendersonFilter(int length) { if (length % 2 == 0) throw new LinearFilterException("Invalid length for Henderson filter. Should be odd"); int m = length / 2; double[] c = new double[m + 1]; int n = m + 2; double n2 = n * n; for (int i = 0; i < m + 1; i++) { double ii = (i - m) * (i - m); double up = 315 * (n2 - n * 2 + 1 - (ii)); up *= n2 - ii; up *= n2 + n * 2 + 1 - ii; up *= n2 * 3 - 16 - ii * 11; double down = n * 8; down *= n2 - 1; down *= n2 * 4 - 1; down *= n2 * 4 - 9; down *= n2 * 4 - 25; c[m - i] = up / down; } return SymmetricFilter.of(c); } private  TrendCycleFilterFactory(); static SymmetricFilter defaultHendersonFilterForFrequency(
	    final int frequency); static SymmetricFilter makeHendersonFilter(int length); static SymmetricFilter makeTrendFilter(final int frequency);  }