]>
Commit | Line | Data |
---|---|---|
88840341 | 1 | /* |
88840341 RC |
2 | chronyd/chronyc - Programs for keeping computer clocks accurate. |
3 | ||
4 | ********************************************************************** | |
5 | * Copyright (C) Richard P. Curnow 1997-2002 | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of version 2 of the GNU General Public License as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, but | |
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License along | |
17 | * with this program; if not, write to the Free Software Foundation, Inc., | |
8e23110a | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
88840341 RC |
19 | * |
20 | ********************************************************************** | |
21 | ||
22 | ======================================================================= | |
23 | ||
24 | Header file for regression routine(s) | |
25 | ||
26 | */ | |
27 | ||
28 | #ifndef GOT_REGRESS_H | |
29 | #define GOT_REGRESS_H | |
30 | ||
31 | extern void | |
32 | RGR_WeightedRegression | |
33 | (double *x, /* independent variable */ | |
34 | double *y, /* measured data */ | |
35 | double *w, /* weightings (large => data | |
36 | less reliable) */ | |
37 | ||
38 | int n, /* number of data points */ | |
39 | ||
40 | /* And now the results */ | |
41 | ||
42 | double *b0, /* estimated y axis intercept */ | |
43 | double *b1, /* estimated slope */ | |
44 | double *s2, /* estimated variance (weighted) of | |
45 | data points */ | |
46 | ||
47 | double *sb0, /* estimated standard deviation of | |
48 | intercept */ | |
49 | double *sb1 /* estimated standard deviation of | |
50 | slope */ | |
51 | ||
52 | /* Could add correlation stuff later if required */ | |
53 | ); | |
54 | ||
55 | /* Return the weighting to apply to the standard deviation to get a | |
56 | given size of confidence interval assuming a T distribution */ | |
57 | ||
58 | extern double RGR_GetTCoef(int dof); | |
59 | ||
b9b0326d ML |
60 | /* Return the value to apply to the variance to make an upper one-sided |
61 | test assuming a chi-square distribution. */ | |
62 | ||
63 | extern double RGR_GetChi2Coef(int dof); | |
64 | ||
e591e362 ML |
65 | /* Maximum ratio of number of points used for runs test to number of regression |
66 | points */ | |
67 | #define REGRESS_RUNS_RATIO 2 | |
68 | ||
ae104b5c ML |
69 | /* Minimum number of samples for regression */ |
70 | #define MIN_SAMPLES_FOR_REGRESS 3 | |
71 | ||
88840341 RC |
72 | /* Return a status indicating whether there were enough points to |
73 | carry out the regression */ | |
74 | ||
75 | extern int | |
76 | RGR_FindBestRegression | |
77 | (double *x, /* independent variable */ | |
78 | double *y, /* measured data */ | |
79 | double *w, /* weightings (large => data | |
80 | less reliable) */ | |
81 | ||
82 | int n, /* number of data points */ | |
e591e362 ML |
83 | int m, /* number of extra samples in x and y arrays |
84 | (negative index) which can be used to | |
85 | extend runs test */ | |
6d2fb9f7 ML |
86 | int min_samples, /* minimum number of samples to be kept after |
87 | changing the starting index to pass the runs | |
88 | test */ | |
88840341 RC |
89 | |
90 | /* And now the results */ | |
91 | ||
92 | double *b0, /* estimated y axis intercept */ | |
93 | double *b1, /* estimated slope */ | |
94 | double *s2, /* estimated variance of data points */ | |
95 | ||
96 | double *sb0, /* estimated standard deviation of | |
97 | intercept */ | |
98 | double *sb1, /* estimated standard deviation of | |
99 | slope */ | |
100 | ||
101 | int *new_start, /* the new starting index to make the | |
102 | residuals pass the two tests */ | |
103 | ||
104 | int *n_runs, /* number of runs amongst the residuals */ | |
105 | ||
106 | int *dof /* degrees of freedom in statistics (needed | |
107 | to get confidence intervals later) */ | |
108 | ||
109 | ); | |
110 | ||
111 | int | |
112 | RGR_FindBestRobustRegression | |
113 | (double *x, | |
114 | double *y, | |
115 | int n, | |
116 | double tol, | |
117 | double *b0, | |
118 | double *b1, | |
119 | int *n_runs, | |
120 | int *best_start); | |
121 | ||
27d59e54 ML |
122 | int |
123 | RGR_MultipleRegress | |
124 | (double *x1, /* first independent variable */ | |
125 | double *x2, /* second independent variable */ | |
126 | double *y, /* measured data */ | |
127 | ||
128 | int n, /* number of data points */ | |
129 | ||
130 | /* The results */ | |
131 | double *b2 /* estimated second slope */ | |
132 | ); | |
133 | ||
6207655a ML |
134 | /* Return the median value from an array */ |
135 | extern double RGR_FindMedian(double *x, int n); | |
136 | ||
88840341 | 137 | #endif /* GOT_REGRESS_H */ |