/* nag_robust_m_estim_1var(g07dbc) Example Program. * * Copyright 1996 Numerical Algorithms Group. * * Mark 4, 1996. * * Mark 6 revised, 2000. */ #include #include #include #include #include #define NMAX 25 int main(void) { double dchi; double c; double x[NMAX], sigma, theta; double h1, h2, h3, rs[NMAX]; double thesav, sigsav; double tol, wrk[NMAX]; Integer i; Integer n; Integer maxit; Integer isigma; Integer nit; char sigma_enum_str[20]; Nag_SigmaSimulEst sigma_enum; Vprintf("g07dbc Example Program Results\n\n"); /* Skip heading in data file */ Vscanf("%*[^\n]\n"); Vscanf("%ld %*[^\n]\n",&n); if (n <= NMAX) { for (i = 1; i <= n; ++i) Vscanf("%lf", &x[i - 1]); Vscanf("%*[^\n]\n"); Vscanf("%lf %lf %lf %lf %ld %*[^\n]\n", &h1,&h2,&h3,&dchi,&maxit); Vprintf("%25sInput parameters Output parameters\n",""); Vprintf(" sigma_est sigma theta tol sigma theta\n\n"); while ((scanf("%ld %lf %lf %lf%*[^\n]", &isigma,&sigma,&theta,&tol)) != EOF) { if (isigma == 1) { sigma_enum = Nag_SigmaSimul; strcpy(sigma_enum_str, "Nag_SigmaSimul"); } else if (isigma == 0) { sigma_enum = Nag_SigmaBypas; strcpy(sigma_enum_str, "Nag_SigmaBypas"); } sigsav = sigma; thesav = theta; c = 0.0; g07dbc(sigma_enum, n, x, Nag_HampelFun, c, h1, h2, h3, dchi, &theta, &sigma, maxit, tol, rs, &nit, wrk, NAGERR_DEFAULT); Vprintf("%s %8.4f %8.4f %7.4f %9.4f %8.4f\n", sigma_enum_str, sigsav, thesav,tol,sigma,theta); } return EXIT_SUCCESS; } else { Vprintf("n is out of range: n =%ld\n", n); return EXIT_SUCCESS; } }