43 const double *Y_Sigma,
50 double s,
sx, sxx, sxy,
sy, syy, delta;
51 double pop_sd_x, pop_sd_y;
82 if (Y_Sigma == NULL) {
106 if (Correlation == NULL)
120 for (i = 0 ; i < Size ; i++) {
123 if (Y_Sigma[i] <= 0.0) {
127 t = 1.0 / (Y_Sigma[i] * Y_Sigma[i]);
131 sxx += (X[i] * X[i]) * t;
132 sxy += (X[i] * Y[i]) * t;
133 syy += (Y[i] * Y[i]) * t;
136 delta = s * sxx - sx *
sx;
142 pop_sd_x = sqrt(s*sxx-sx*sx);
143 pop_sd_y = sqrt(s*syy-sy*sy);
145 if (pop_sd_x == 0.0 || pop_sd_y == 0.0) {
149 *A = (sxx * sy - sx * sxy) / delta;
150 *B = (s * sxy - sx *
sy) / delta;
152 *Correlation = ( ((s * sxy) - (sx * sy)) /
153 ( pop_sd_x * pop_sd_y )
MTKt_status MtkLinearRegressionCalc(int Size, const double *X, const double *Y, const double *Y_Sigma, double *A, double *B, double *Correlation)
Use linear regression to fit a set of observations (x,y) to the model: y(x) = a + b * x...
#define MTK_ERR_CODE_JUMP(code)