/* nag_tsa_spectrum_univar(g13cbc) Example Program. * * Copyright 1996 Numerical Algorithms Group. * * Mark 4, 1996. * */ #include #include #include #include #define KCMAX 400 #define NXMAX KCMAX/2 int main(void) { double stats[4]; double x[KCMAX], xh[NXMAX], *g; double pw, px; Integer i, l; Integer kc, ng; Integer mw, nx; Vprintf("g13cbc Example Program Results\n"); /* Skip heading in data file */ Vscanf("%*[^\n] "); Vscanf("%ld ",&nx); if (nx > 0 && nx <= NXMAX) { for (i = 1; i <= nx; ++i) Vscanf("%lf ", &xh[i - 1]); px = 0.2; mw = nx; pw = 0.5; kc = KCMAX; l = 100; while ((scanf("%ld ", &mw)) != EOF) { if (mw > 0 && mw <= nx) { for (i = 1; i <= nx; ++i) x[i - 1] = xh[i - 1]; g13cbc(nx, Nag_Mean, px, mw, pw, l, kc, Nag_Logged, x, &g, &ng, stats, NAGERR_DEFAULT); if (mw == nx) Vprintf("\n No smoothing\n\n"); else Vprintf("\n Frequency width of smoothing window = 1/%ld\n\n", mw); Vprintf(" Degrees of freedom =%4.1f Bandwidth =%7.4f\n\n", stats[0],stats[3]); Vprintf(" 95 percent confidence limits - Lower =%7.4f " "Upper =%7.4f\n\n", stats[1], stats[2]); Vprintf(" Spectrum Spectrum Spectrum" " Spectrum\n"); Vprintf(" estimate estimate estimate" " estimate\n\n"); for (i = 1; i <= ng; ++i) Vprintf("%5ld%10.4f%s",i,g[i - 1], (i%4==0 ? "\n": "")); Vprintf("\n"); if (g) NAG_FREE(g); } } } return EXIT_SUCCESS; }