Changeset 2843 for trunk/Ohana/src/opihi/lib.data/mrq2dmin.c
- Timestamp:
- Dec 28, 2004, 8:40:04 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.data/mrq2dmin.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.data/mrq2dmin.c
r2598 r2843 2 2 3 3 /* need to pass in a function of the form: 4 5 funcs (x, t, a, Npar, dyda) 6 7 returns f (x, t) for Npar parameters a, also df/da at x,t 8 4 funcs (x, t, a, Npar, dy/da) 5 returns y (x,t) for Npar parameters a along with dy/da at (x,t) 9 6 dy carries 1/sig^2 10 11 7 */ 12 8 … … 21 17 22 18 int k, j, i; 23 float ydiff, wt, chisq , value;19 float ydiff, wt, chisq; 24 20 25 21 for (j = 0; j < Npar; j++) { … … 32 28 33 29 ydiff = funcs (x[i], t[i], par, Npar, dyda) - y[i]; 34 value = SQ(ydiff) * fabs(dy[i]); 35 if (value < 0.0) fprintf (stderr, "neg chi: %f %f\n", value, chisq); 36 chisq += value; 30 chisq += SQ(ydiff) * dy[i]; 37 31 38 if (!finite (dyda[i])) { dyda[i] = 1e10; }39 if (!finite (dy[i])) { dyda[i] = 1e10; }40 41 32 for (j = 0; j < Npar; j++) { 42 33 wt = dyda[j] * dy[i]; … … 56 47 float mrq2dmin (float *x, float *t, float *y, float *dy, int Npts, 57 48 float *par, int Npar, 58 float (funcs)(float, float, float *, int, float *) ) {49 float (funcs)(float, float, float *, int, float *), int VERBOSE) { 59 50 60 51 int j, k; … … 68 59 } 69 60 61 /* keep this test in here? */ 70 62 if (!fgaussj (talpha, Npar, tbeta, 1)) { 71 63 lambda *= 10.0; … … 73 65 } 74 66 75 /* if we keep some fixed, set partry to just them76 for (j = 0; j < Npar; j++) partry[j] = par[j]; */77 78 67 for (j = 0; j < Npar; j++) partry[j] = par[j] - tbeta[j][0]; 79 68 80 69 chisq = mrq2dcof (x, t, y, dy, Npts, partry, Npar, talpha, tbeta, funcs); 70 if (VERBOSE) { 71 fprintf (stderr, "chisq: %f ", chisq); 72 fprintf (stderr, "lambda: %f ", lambda); 73 for (j = 0; j < Npar; j++) { 74 fprintf (stderr, "%f ", partry[j]); 75 } 76 fprintf (stderr, "\n"); 77 } 81 78 82 79 /* if good, save temp values */ … … 100 97 float mrq2dinit (float *x, float *t, float *y, float *dy, int Npts, 101 98 float *par, int Npar, 102 float (funcs)(float, float, float *, int, float *) ) {99 float (funcs)(float, float, float *, int, float *), int VERBOSE) { 103 100 104 101 int i; … … 121 118 122 119 ochisq = mrq2dcof (x, t, y, dy, Npts, par, Npar, alpha, beta, funcs); 120 if (VERBOSE) { 121 fprintf (stderr, "chisq: %f ", ochisq); 122 fprintf (stderr, "lambda: %f ", lambda); 123 for (i = 0; i < Npar; i++) { 124 fprintf (stderr, "%f ", par[i]); 125 } 126 fprintf (stderr, "\n"); 127 } 123 128 124 129 return (ochisq);
Note:
See TracChangeset
for help on using the changeset viewer.
