|
template<domain D :shared3p > |
D float32 | linearRegressionCG (D int32[[2]] variables, D int32[[1]] dependent, uint iterations) |
|
template<domain D :shared3p > |
D float64 | linearRegressionCG (D int64[[2]] variables, D int64[[1]] dependent, uint iterations) |
|
template<domain D :shared3p > |
D float32 | linearRegressionCG (D float32[[2]] variables, D float32[[1]] dependent, uint iterations) |
|
template<domain D :shared3p > |
D float64 | linearRegressionCG (D float64[[2]] variables, D float64[[1]] dependent, uint iterations) |
|
Fitting of linear models with multiple explanatory variables using the conjugate gradient method.
- Note
- D - shared3p protection domain
-
Supported types - int32 / int64 / float32 / float64
-
You can pass an empty matrix as the variables argument to specify a null model with just intercept.
- Parameters
-
variables | - a matrix where each column is a sample of an explanatory variable |
dependent | - sample vector of dependent variable |
iterations | - number of iterations to use. Empirical testing showed that 10 iterations provides better accuracy than LU decomposition and Gaussian elimination and with a high number of variables it is also faster. |
- Returns
- returns vector {β_1, β_1, …, β_n} such that y ≈ β_1 * x_1 + β_2 * x_2 + … + β_(n-1) * x_(n-1) + β_n where y is the dependent variable and x_i are the explanatory variables.
- Leakage
- None
◆ linearRegressionCG() [1/4]
D float32 linearRegressionCG |
( |
D float32[[2]] |
variables, |
|
|
D float32[[1]] |
dependent, |
|
|
uint |
iterations |
|
) |
| |
◆ linearRegressionCG() [2/4]
D float64 linearRegressionCG |
( |
D float64[[2]] |
variables, |
|
|
D float64[[1]] |
dependent, |
|
|
uint |
iterations |
|
) |
| |
◆ linearRegressionCG() [3/4]
D float32 linearRegressionCG |
( |
D int32[[2]] |
variables, |
|
|
D int32[[1]] |
dependent, |
|
|
uint |
iterations |
|
) |
| |
◆ linearRegressionCG() [4/4]
D float64 linearRegressionCG |
( |
D int64[[2]] |
variables, |
|
|
D int64[[1]] |
dependent, |
|
|
uint |
iterations |
|
) |
| |