2 chronyd/chronyc - Programs for keeping computer clocks accurate.
4 **********************************************************************
5 * Copyright (C) Richard P. Curnow 1997-2002
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.
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.
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.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 **********************************************************************
22 =======================================================================
24 Header file for regression routine(s)
32 RGR_WeightedRegression
33 (double *x
, /* independent variable */
34 double *y
, /* measured data */
35 double *w
, /* weightings (large => data
38 int n
, /* number of data points */
40 /* And now the results */
42 double *b0
, /* estimated y axis intercept */
43 double *b1
, /* estimated slope */
44 double *s2
, /* estimated variance (weighted) of
47 double *sb0
, /* estimated standard deviation of
49 double *sb1
/* estimated standard deviation of
52 /* Could add correlation stuff later if required */
55 /* Return the weighting to apply to the standard deviation to get a
56 given size of confidence interval assuming a T distribution */
58 extern double RGR_GetTCoef(int dof
);
60 /* Return the value to apply to the variance to make an upper one-sided
61 test assuming a chi-square distribution. */
63 extern double RGR_GetChi2Coef(int dof
);
65 /* Maximum ratio of number of points used for runs test to number of regression
67 #define REGRESS_RUNS_RATIO 2
69 /* Minimum number of samples for regression */
70 #define MIN_SAMPLES_FOR_REGRESS 3
72 /* Return a status indicating whether there were enough points to
73 carry out the regression */
76 RGR_FindBestRegression
77 (double *x
, /* independent variable */
78 double *y
, /* measured data */
79 double *w
, /* weightings (large => data
82 int n
, /* number of data points */
83 int m
, /* number of extra samples in x and y arrays
84 (negative index) which can be used to
86 int min_samples
, /* minimum number of samples to be kept after
87 changing the starting index to pass the runs
90 /* And now the results */
92 double *b0
, /* estimated y axis intercept */
93 double *b1
, /* estimated slope */
94 double *s2
, /* estimated variance of data points */
96 double *sb0
, /* estimated standard deviation of
98 double *sb1
, /* estimated standard deviation of
101 int *new_start
, /* the new starting index to make the
102 residuals pass the two tests */
104 int *n_runs
, /* number of runs amongst the residuals */
106 int *dof
/* degrees of freedom in statistics (needed
107 to get confidence intervals later) */
112 RGR_FindBestRobustRegression
124 (double *x1
, /* first independent variable */
125 double *x2
, /* second independent variable */
126 double *y
, /* measured data */
128 int n
, /* number of data points */
131 double *b2
/* estimated second slope */
134 /* Return the median value from an array */
135 extern double RGR_FindMedian(double *x
, int n
);
137 #endif /* GOT_REGRESS_H */