Back to index

radiance  4R0+20100331
Functions | Variables
linregr.c File Reference
#include "copyright.h"
#include <math.h>
#include "linregr.h"

Go to the source code of this file.

Functions

void lrclear (LRSUM *l)
int flrpoint (double x, double y, LRSUM *l)
int lrfit (LRLIN *r, LRSUM *l)

Variables

static const char RCSid [] = "$Id: linregr.c,v 2.4 2003/02/25 02:47:21 greg Exp $"

Function Documentation

int flrpoint ( double  x,
double  y,
LRSUM l 
)

Definition at line 25 of file linregr.c.

{
       l->xs += x;
       l->ys += y;
       l->xxs += x*x;
       l->yys += y*y;
       l->xys += x*y;
       return(++l->n);
}
void lrclear ( LRSUM l)

Definition at line 16 of file linregr.c.

{
       l->xs = l->ys = l->xxs = l->yys = l->xys = 0.0;
       l->n = 0;
}

Here is the caller graph for this function:

int lrfit ( LRLIN r,
LRSUM l 
)

Definition at line 39 of file linregr.c.

{
       double nxvar, nyvar;

       if (l->n < 2)
              return(-1);
       nxvar = l->xxs - l->xs*l->xs/l->n;
       nyvar = l->yys - l->ys*l->ys/l->n;
       if (nxvar == 0.0 || nyvar == 0.0)
              return(-1);
       r->slope = (l->xys - l->xs*l->ys/l->n) / nxvar;
       r->intercept = (l->ys - r->slope*l->xs) / l->n;
       r->correlation = r->slope*sqrt(nxvar/nyvar);
       return(0);
}

Here is the caller graph for this function:


Variable Documentation

const char RCSid[] = "$Id: linregr.c,v 2.4 2003/02/25 02:47:21 greg Exp $" [static]

Definition at line 2 of file linregr.c.