LinearRegression.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2024 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/Util/stat/LinearRegression.h
10
11#ifndef __Util_stat_LinearRegression_h
12#define __Util_stat_LinearRegression_h
13
14#include "Estimate.h"
15#include <vector>
16
17class LinearRegression
18{
19public:
20
22
23 float iterative_outlier_threshold = 0.0;
24
26 bool subtract_weighted_mean_abscissa = false;
27
29 Estimate<double> scale;
30
32 Estimate<double> offset;
33
35 double covariance = 0.0;
36
38 double weighted_mean_abscissa = 0.0;
39
41 double chisq = 0.0;
42
44 unsigned nfree = 0;
45
47 void ordinary_least_squares (const std::vector<double>& yval,
48 const std::vector<double>& xval,
49 const std::vector<bool>* mask = 0);
50
52
53 void weighted_least_squares (const std::vector<double>& yval,
54 const std::vector<double>& xval,
55 const std::vector<double>& weight);
56
58
62 void generalized_least_squares (const std::vector<double>& yval,
63 const std::vector<double>& xval,
64 const std::vector<double>& weight,
65 const std::vector<double>& alpha);
66
67 /* the inner loop of generalized_least_squares, which may iteratively remove outliers */
68 void least_squares_worker (const std::vector<double>& yval,
69 const std::vector<double>& xval,
70 const std::vector<double>& weight,
71 const std::vector<double>& alpha);
72
74 std::vector<double> masked_weights;
75
76 protected:
78 std::vector<double> residual;
79};
80
81#endif

Generated using doxygen 1.14.0