Linear regression calculator using least squares method.
Computes the best-fit line y = c + m*x that minimizes the sum of squared residuals. Uses GSL for numerical computation.
Computed Statistics
| Field | Description |
| c | Y-intercept |
| m | Slope |
| r2 | Coefficient of determination (0-1) |
| sumsq | Sum of squared residuals |
| sigma | Standard deviation of errors |
| mse | Mean squared error |
Definition at line 98 of file lfit.H.
Construct and compute linear regression.
Fits the model y = c + m*x to minimize sum of squared errors. Computes R², standard deviation, and MSE.
- Parameters
-
| x | Array of independent variable values |
| y | Array of dependent variable values |
- Exceptions
-
- Example
Array<double>
y = {2, 4, 6, 8};
Simple dynamic array with automatic resizing and functional operations.
Linear regression calculator using least squares method.
Definition at line 149 of file lfit.H.
References ALEPHTHROW, Aleph::Array< T >::base(), c, cov00, cov01, cov11, Aleph::diff(), Aleph::divide_and_conquer_partition_dp(), Aleph::error(), Aleph::is_normal_number(), m, mse, Aleph::pow2(), r2, sigma, Aleph::Array< T >::size(), sqrt(), sumsq, y, and Aleph::zip_it().
Predict y-value and error for given x.
Uses the fitted model to predict y at the given x value, along with an error estimate based on the covariance matrix.
- Parameters
-
| x | Independent variable value |
- Returns
- Pair (predicted_y, error_estimate)
- Example
auto [
y,
err] = fit.predict(10.0);
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Definition at line 202 of file lfit.H.
References c, cov00, cov01, cov11, Aleph::divide_and_conquer_partition_dp(), m, and y.
Referenced by TEST_F(), TEST_F(), TEST_F(), and TEST_F().