/** Test of the Iz periodgram. */ @Test public void testPeriodgramIzWithZeroData() { System.out.println("test Iz periodogram with data all zeros"); final int N = 10; final double Tmin = 0.7; final double Tmax = 1.2; final double q = 10; final double[] y = new double[N]; for (int i = 0; i < y.length; i++) y[i] = 0.0; QuantisedPeriodogramFFT instance = new QuantisedPeriodogramFFT(N, Tmin, Tmax, q); instance.estimate(y); for (double f = 0; f <= q; f += 0.01) assertEquals(instance.Iz(f), N * N, 0.000001); }
/** Test of the D against B */ @Test public void testPeriodgramIzAgainstD() { System.out.println("test slow Iz versus fast FFT computed D"); final int N = 10; final double Tmin = 0.7; final double Tmax = 1.2; final double q = 10; final double[] y = new double[N]; for (int i = 0; i < y.length; i++) y[i] = 1.0 * i; QuantisedPeriodogramFFT instance = new QuantisedPeriodogramFFT(N, Tmin, Tmax, q); instance.estimate(y); int M = instance.M(); // set M to minimum possible double W = q / M; // width of the search grid Complex[] D = instance.computeV(); // compute the vector D by FFT int K = (int) Math.floor((instance.fmax - instance.fmin) / W); for (int k = 0; k < K; k++) { double f = instance.fmin + W * k; assertEquals(instance.Iz(f), D[k].abs2(), 0.000001); } }