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;
53 denom -= count * xbar * xbar;
57 for (i = 0; i < n; i++)
59 denom2 += values[i] * values[i];
60 denom2 -= count * ybar * ybar;
61 Rsq = (numer * numer) / (denom * denom2);
66 *result = numer / denom;
69 *result = ybar - xbar * numer / denom;
75 *result = sqrt(Rsq * (count - 2) / (1 - Rsq));
83 if (*result != *result)
107 static void regression_w(
DCELL * result,
DCELL(*values)[2],
int n,
int which)
111 DCELL numer, denom, denom2;
119 for (i = 0; i < n; i++) {
123 xsum += i * values[i][1];
124 ysum += values[i][0] * values[i][1];
125 count += values[i][1];
137 for (i = 0; i < n; i++)
139 numer += i * values[i][0] * values[i][1];
140 numer -= count * xbar * ybar;
143 for (i = 0; i < n; i++)
145 denom += (
DCELL) i * i * values[i][1];
147 denom -= count * xbar * xbar;
151 for (i = 0; i < n; i++)
153 denom2 += values[i][0] * values[i][0] * values[i][1];
154 denom2 -= count * ybar * ybar;
155 Rsq = (numer * numer) / (denom * denom2);
160 *result = numer / denom;
163 *result = ybar - xbar * numer / denom;
169 *result = sqrt(Rsq * (count - 2) / (1 - Rsq));
177 if (*result != *result)
void w_reg_c(DCELL *result, DCELL(*values)[2], int n, const void *closure)
void c_reg_r2(DCELL *result, DCELL *values, int n, const void *closure)
#define Rast_is_d_null_value(dcellVal)
void w_reg_m(DCELL *result, DCELL(*values)[2], int n, const void *closure)
void c_reg_c(DCELL *result, DCELL *values, int n, const void *closure)
void w_reg_r2(DCELL *result, DCELL(*values)[2], int n, const void *closure)
void w_reg_t(DCELL *result, DCELL(*values)[2], int n, const void *closure)
void c_reg_t(DCELL *result, DCELL *values, int n, const void *closure)
void c_reg_m(DCELL *result, DCELL *values, int n, const void *closure)
void Rast_set_d_null_value(DCELL *, int)
To set a number of DCELL raster values to NULL.