14 static void regression(
DCELL *result,
DCELL *values,
int n,
int which)
18 DCELL numer, denom, denom2;
26 for (i = 0; i < n; i++) {
44 for (i = 0; i < n; i++)
46 numer += i * values[i];
47 numer -=
count * xbar * ybar;
50 for (i = 0; i < n; i++)
52 denom += (
DCELL)i * i;
54 denom -=
count * xbar * xbar;
58 for (i = 0; i < n; i++)
60 denom2 += values[i] * values[i];
61 denom2 -=
count * ybar * ybar;
62 Rsq = (numer * numer) / (denom * denom2);
67 *result = numer / denom;
70 *result = ybar - xbar * numer / denom;
76 *result = sqrt(Rsq * (
count - 2) / (1 - Rsq));
84 if (*result != *result)
108 static void regression_w(
DCELL *result,
DCELL (*values)[2],
int n,
int which)
112 DCELL numer, denom, denom2;
120 for (i = 0; i < n; i++) {
124 xsum += i * values[i][1];
125 ysum += values[i][0] * values[i][1];
126 count += values[i][1];
138 for (i = 0; i < n; i++)
140 numer += i * values[i][0] * values[i][1];
141 numer -=
count * xbar * ybar;
144 for (i = 0; i < n; i++)
146 denom += (
DCELL)i * i * values[i][1];
148 denom -=
count * xbar * xbar;
152 for (i = 0; i < n; i++)
154 denom2 += values[i][0] * values[i][0] * values[i][1];
155 denom2 -=
count * ybar * ybar;
156 Rsq = (numer * numer) / (denom * denom2);
161 *result = numer / denom;
164 *result = ybar - xbar * numer / denom;
170 *result = sqrt(Rsq * (
count - 2) / (1 - Rsq));
178 if (*result != *result)
183 const void *closure
UNUSED)
189 const void *closure
UNUSED)
195 const void *closure
UNUSED)
201 const void *closure
UNUSED)
void w_reg_m(DCELL *result, DCELL(*values)[2], int n, const void *closure UNUSED)
void c_reg_c(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
void w_reg_c(DCELL *result, DCELL(*values)[2], int n, const void *closure UNUSED)
void c_reg_r2(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
void w_reg_t(DCELL *result, DCELL(*values)[2], int n, const void *closure UNUSED)
void c_reg_t(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
void c_reg_m(DCELL *result, DCELL *values, int n, const void *closure UNUSED)
void w_reg_r2(DCELL *result, DCELL(*values)[2], int n, const void *closure UNUSED)
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.
#define Rast_is_d_null_value(dcellVal)
#define UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.