1 |
greg |
1.1 |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
|
3 |
|
|
/* SCCSid "$SunId$ LBL" */ |
4 |
|
|
|
5 |
|
|
/* |
6 |
|
|
* Header file for linear regression calculation. |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
typedef struct { |
10 |
|
|
double xs, ys, xxs, yys, xys; |
11 |
|
|
int n; |
12 |
|
|
} LRSUM; |
13 |
|
|
|
14 |
|
|
typedef struct { |
15 |
|
|
double slope, intercept, correlation; |
16 |
|
|
} LRLIN; |
17 |
|
|
|
18 |
|
|
extern double sqrt(); |
19 |
|
|
|
20 |
|
|
#define lrpoint(x,y,l) ((l)->xs+=(x),(l)->ys+=(y),(l)->xxs+=(x)*(x), \ |
21 |
|
|
(l)->yys+=(y)*(y),(l)->xys+=(x)*(y),++(l)->n) |
22 |
|
|
|
23 |
|
|
#define lrxavg(l) ((l)->xs/(l)->n) |
24 |
|
|
#define lryavg(l) ((l)->ys/(l)->n) |
25 |
|
|
#define lrxvar(l) (((l)->xxs-(l)->xs*(l)->xs/(l)->n)/(l)->n) |
26 |
|
|
#define lryvar(l) (((l)->yys-(l)->ys*(l)->ys/(l)->n)/(l)->n) |
27 |
|
|
#define lrxdev(l) sqrt(((l)->xxs-(l)->xs*(l)->xs/(l)->n)/((l)->n-1)) |
28 |
|
|
#define lrydev(l) sqrt(((l)->yys-(l)->ys*(l)->ys/(l)->n)/((l)->n-1)) |