1 |
greg |
2.6 |
/* RCSid $Id: linregr.h,v 2.5 2003/06/06 16:38:47 schorsch Exp $ */ |
2 |
greg |
1.1 |
/* |
3 |
|
|
* Header file for linear regression calculation. |
4 |
|
|
*/ |
5 |
schorsch |
2.5 |
#ifndef _RAD_LINEGR_H_ |
6 |
|
|
#define _RAD_LINEGR_H_ |
7 |
|
|
#ifdef __cplusplus |
8 |
|
|
extern "C" { |
9 |
|
|
#endif |
10 |
greg |
2.3 |
|
11 |
greg |
1.1 |
typedef struct { |
12 |
|
|
double xs, ys, xxs, yys, xys; |
13 |
|
|
int n; |
14 |
|
|
} LRSUM; |
15 |
|
|
|
16 |
|
|
typedef struct { |
17 |
|
|
double slope, intercept, correlation; |
18 |
|
|
} LRLIN; |
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)) |
29 |
greg |
2.3 |
|
30 |
|
|
|
31 |
|
|
extern void lrclear(LRSUM *l); |
32 |
|
|
extern int flrpoint(double x, double y, LRSUM *l); |
33 |
|
|
extern int lrfit(LRLIN *r, LRSUM *l); |
34 |
|
|
|
35 |
schorsch |
2.5 |
|
36 |
|
|
#ifdef __cplusplus |
37 |
|
|
} |
38 |
greg |
2.3 |
#endif |
39 |
schorsch |
2.5 |
#endif /* _RAD_LINEGR_H_ */ |
40 |
|
|
|