Back to index

radiance  4R0+20100331
Classes | Defines | Functions
linregr.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  LRSUM
struct  LRLIN

Defines

#define lrpoint(x, y, l)
#define lrxavg(l)   ((l)->xs/(l)->n)
#define lryavg(l)   ((l)->ys/(l)->n)
#define lrxvar(l)   (((l)->xxs-(l)->xs*(l)->xs/(l)->n)/(l)->n)
#define lryvar(l)   (((l)->yys-(l)->ys*(l)->ys/(l)->n)/(l)->n)
#define lrxdev(l)   sqrt(((l)->xxs-(l)->xs*(l)->xs/(l)->n)/((l)->n-1))
#define lrydev(l)   sqrt(((l)->yys-(l)->ys*(l)->ys/(l)->n)/((l)->n-1))

Functions

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

Class Documentation

struct LRSUM

Definition at line 11 of file linregr.h.

Class Members
int n
double xs
double xxs
double xys
double ys
double yys
struct LRLIN

Definition at line 16 of file linregr.h.

Class Members
double correlation
double intercept
double slope

Define Documentation

#define lrpoint (   x,
  y,
 
)
Value:
((l)->xs+=(x),(l)->ys+=(y),(l)->xxs+=(x)*(x), \
                     (l)->yys+=(y)*(y),(l)->xys+=(x)*(y),++(l)->n)

Definition at line 20 of file linregr.h.

#define lrxavg (   l)    ((l)->xs/(l)->n)

Definition at line 23 of file linregr.h.

#define lrxdev (   l)    sqrt(((l)->xxs-(l)->xs*(l)->xs/(l)->n)/((l)->n-1))

Definition at line 27 of file linregr.h.

#define lrxvar (   l)    (((l)->xxs-(l)->xs*(l)->xs/(l)->n)/(l)->n)

Definition at line 25 of file linregr.h.

#define lryavg (   l)    ((l)->ys/(l)->n)

Definition at line 24 of file linregr.h.

#define lrydev (   l)    sqrt(((l)->yys-(l)->ys*(l)->ys/(l)->n)/((l)->n-1))

Definition at line 28 of file linregr.h.

#define lryvar (   l)    (((l)->yys-(l)->ys*(l)->ys/(l)->n)/(l)->n)

Definition at line 26 of file linregr.h.


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: