rcb               272 core/gps_math.c void regressionInit (t_regression *rcb, int size, t_regression_xy buffer[]) {
rcb               273 core/gps_math.c     rcb->size       = size;
rcb               274 core/gps_math.c     rcb->values     = buffer;
rcb               275 core/gps_math.c     regressionReset (rcb);
rcb               282 core/gps_math.c void regressionReset (t_regression *rcb) {
rcb               284 core/gps_math.c     rcb->n          = 0;
rcb               285 core/gps_math.c     rcb->sx         = 0.0;
rcb               286 core/gps_math.c     rcb->sy         = 0.0;
rcb               287 core/gps_math.c     rcb->sxx        = 0.0;
rcb               288 core/gps_math.c     rcb->sxy        = 0.0;
rcb               289 core/gps_math.c     rcb->last_x     = 0.0;
rcb               290 core/gps_math.c     rcb->valid      = 0;
rcb               291 core/gps_math.c     rcb->s          = 0.0;
rcb               292 core/gps_math.c     rcb->t          = 0.0;
rcb               293 core/gps_math.c     rcb->index      = 0;
rcb               294 core/gps_math.c     for (i=0; i<rcb->size; i++) {
rcb               295 core/gps_math.c         rcb->values[i].x = 0;
rcb               296 core/gps_math.c         rcb->values[i].y = 0;
rcb               304 core/gps_math.c void regressionAdd (t_regression *rcb, double x, double y) {
rcb               308 core/gps_math.c     if (rcb->n >= rcb->size) {
rcb               309 core/gps_math.c         double old_x   = rcb->values[rcb->index].x;
rcb               310 core/gps_math.c         double old_y   = rcb->values[rcb->index].y;
rcb               311 core/gps_math.c         rcb->values[rcb->index].x = 0;
rcb               312 core/gps_math.c         rcb->values[rcb->index].y = 0;
rcb               313 core/gps_math.c         rcb->n          -= 1;
rcb               314 core/gps_math.c         rcb->sx         -= old_x;
rcb               315 core/gps_math.c         rcb->sy         -= old_y;
rcb               316 core/gps_math.c         rcb->sxx        -= old_x*old_x;
rcb               317 core/gps_math.c         rcb->sxy        -= old_x*old_y;
rcb               318 core/gps_math.c         rcb->valid      = 0;
rcb               319 core/gps_math.c         rcb->s          = 0.0;
rcb               320 core/gps_math.c         rcb->t          = 0.0;
rcb               323 core/gps_math.c     if (rcb->n < rcb->size) {
rcb               324 core/gps_math.c         rcb->n          += 1;
rcb               325 core/gps_math.c         rcb->sx         += x;
rcb               326 core/gps_math.c         rcb->sy         += y;
rcb               327 core/gps_math.c         rcb->sxx        += x*x;
rcb               328 core/gps_math.c         rcb->sxy        += x*y;
rcb               329 core/gps_math.c         rcb->valid      = 0;
rcb               330 core/gps_math.c         rcb->s          = 0.0;
rcb               331 core/gps_math.c         rcb->t          = 0.0;
rcb               332 core/gps_math.c         rcb->last_x     = x;
rcb               333 core/gps_math.c         rcb->values[rcb->index].x = x;
rcb               334 core/gps_math.c         rcb->values[rcb->index].y = y;
rcb               335 core/gps_math.c         rcb->index = (rcb->index+1) % rcb->size;
rcb               343 core/gps_math.c static void regressionCompute (t_regression *rcb) {
rcb               347 core/gps_math.c     if (rcb->valid) return;
rcb               348 core/gps_math.c     rcb->valid = -1;
rcb               350 core/gps_math.c     det = rcb->n*rcb->sxx - rcb->sx*rcb->sx;
rcb               355 core/gps_math.c     rcb->s = (rcb->n * rcb->sxy - rcb->sx * rcb->sy ) / det;
rcb               356 core/gps_math.c     rcb->t = (rcb->sxx*rcb->sy  - rcb->sx * rcb->sxy) / det;
rcb               357 core/gps_math.c     rcb->valid = 1;
rcb               364 core/gps_math.c double regressionActual (t_regression *rcb) {
rcb               365 core/gps_math.c     regressionCompute (rcb);
rcb               366 core/gps_math.c     return rcb->last_x * rcb->s + rcb->t;
rcb               373 core/gps_math.c double regressionForecast (t_regression *rcb, double x) {
rcb               374 core/gps_math.c     regressionCompute (rcb);
rcb               375 core/gps_math.c     return x * rcb->s + rcb->t;
rcb               382 core/gps_math.c double regressionReverse (t_regression *rcb, double y) {
rcb               383 core/gps_math.c     regressionCompute (rcb);
rcb               384 core/gps_math.c     return rcb->s != 0.0 ? (y - rcb->t) / rcb->s : 1e9;
rcb               391 core/gps_math.c double regressionChange (t_regression *rcb) {
rcb               392 core/gps_math.c     regressionCompute (rcb);
rcb               393 core/gps_math.c     return rcb->s;
rcb               402 core/gps_math.c double regressionQuality (t_regression *rcb) {
rcb               403 core/gps_math.c     regressionCompute (rcb);
rcb               404 core/gps_math.c     return rcb->valid==1 ? 1.0 : 0.0;
rcb                74 core/gps_math.h extern void   regressionInit (t_regression *rcb, int size, t_regression_xy buffer[]);
rcb                75 core/gps_math.h extern void   regressionReset (t_regression *rcb);
rcb                76 core/gps_math.h extern void   regressionAdd (t_regression *rcb, double x, double y);
rcb                77 core/gps_math.h extern double regressionActual (t_regression *rcb);
rcb                78 core/gps_math.h extern double regressionForecast (t_regression *rcb, double x);
rcb                79 core/gps_math.h extern double regressionReverse (t_regression *rcb, double y);
rcb                80 core/gps_math.h extern double regressionChange (t_regression *rcb);
rcb                81 core/gps_math.h extern double regressionQuality (t_regression *rcb);