81 double sumx, sumx2, sumx3, sumx4,sumy, sumyx, sumyx2, det;
90 *a = 0; *b = 0; *c = 0;
111 for (i = 0; i <
n; i++)
113 sumx = sumx + w[i] *
x[i];
114 sumx2 = sumx2 + w[i] *
x[i] *
x[i];
115 sumx3 = sumx3 + w[i] *
x[i] *
x[i] *
x[i];
116 sumx4 = sumx4 + w[i] *
x[i] *
x[i] *
x[i] *
x[i];
117 sumy = sumy + w[i] * y[i];
118 sumyx = sumyx + w[i] * y[i] *
x[i];
119 sumyx2 = sumyx2 + w[i] * y[i] *
x[i] *
x[i];
129 HepMatrix
C(3,1), ABC(3,1);
130 D(1,1) = sumx4; D(1,2) = D(2,1) = sumx3; D(1,3) = D(3,1) = D(2,2) = sumx2;
131 D(3,2) = D(2,3) = sumx; D(3,3) =
n;
132 C(1,1) = sumyx2;
C(2,1) = sumyx;
C(3,1) = sumy;
135 ABC = (D.inverse(ierr))*
C;
142 float center = *b/(-2*(*a));
144 for(i = 0; i <
n; i++){
148 if(mean_x > center) *half = 2;
157 chi = chi+(w[i])*((y[i])-*a*(
x[i])-*b)*
158 ((y[i])-*a*(
x[i])-*b);
int QuadFit(float x[], float y[], float w[], int n, float *a, float *b, float *c, int *half, float *chisq, float *siga, float *sigb, float *sigc)