| 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 |  |  | #define lrpoint(x,y,l)  ((l)->xs+=(x),(l)->ys+=(y),(l)->xxs+=(x)*(x), \ | 
| 19 |  |  | (l)->yys+=(y)*(y),(l)->xys+=(x)*(y),++(l)->n) | 
| 20 |  |  |  | 
| 21 |  |  | #define lrxavg(l)       ((l)->xs/(l)->n) | 
| 22 |  |  | #define lryavg(l)       ((l)->ys/(l)->n) | 
| 23 |  |  | #define lrxvar(l)       (((l)->xxs-(l)->xs*(l)->xs/(l)->n)/(l)->n) | 
| 24 |  |  | #define lryvar(l)       (((l)->yys-(l)->ys*(l)->ys/(l)->n)/(l)->n) | 
| 25 |  |  | #define lrxdev(l)       sqrt(((l)->xxs-(l)->xs*(l)->xs/(l)->n)/((l)->n-1)) | 
| 26 |  |  | #define lrydev(l)       sqrt(((l)->yys-(l)->ys*(l)->ys/(l)->n)/((l)->n-1)) |