68# include <gsl/gsl_statistics_double.h>
69# include <gsl/gsl_fit.h>
100 mutable double c = 0;
101 mutable double m = 1;
106 mutable double r2 = 0;
119 return out <<
"r2 = " << f.
r2 << std::endl
120 <<
"sumsq = " << f.
sumsq << std::endl
121 <<
"sigma = " << f.
sigma << std::endl
122 <<
"mse = " << f.
mse << std::endl
123 <<
"c = " << f.
c << std::endl
124 <<
"m = " << f.
m << std::endl;
151 const size_t & n =
y.size();
168 for (
auto it =
zip_it(x,
y); it.has_curr(); it.next_ne())
170 auto t = it.get_curr();
180 return acu + pow2(y - ym);
202 std::pair<double, double>
predict(
double x)
const noexcept
206 return std::make_pair(
y,
y_err);
String manipulation utilities.
Zip iterators and functional operations for multiple containers.
Custom exception classes with source location tracking.
#define ALEPHTHROW(type, msg)
Macro for throwing an aleph exception.
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
T & base()
Return a reference to the first element of array.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_sqrt_function > > sqrt(const __gmp_expr< T, U > &expr)
bool diff(const C1 &c1, const C2 &c2, Eq e=Eq())
Check if two containers differ.
double pow2(const double x)
Return x^2.
void error(const char *file, int line, const char *format,...)
Print an error message with file and line info.
bool is_normal_number(const double n)
Return true if a floating-point number is normal or zero.
ZipIterator< Cs... > zip_it(const Cs &... cs)
Alias for get_zip_it.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Linear regression calculator using least squares method.
LFit(const Array< double > &x, const Array< double > &y)
Construct and compute linear regression.
LFit() noexcept
Default constructor creates an identity fit (y = x)
double cov00
Covariance matrix element (0,0)
double sumsq
Sum of squared residuals.
double cov01
Covariance matrix element (0,1)
std::pair< double, double > predict(double x) const noexcept
Predict y-value and error for given x.
double r2
Coefficient of determination.
double m
Slope of fitted line.
friend std::ostream & operator<<(std::ostream &out, const LFit &f)
Output stream operator for fit results.
double cov11
Covariance matrix element (1,1)
double c
Y-intercept of fitted line.
double mse
Mean squared error.
double sigma
Standard deviation of errors.
Dynamic array container with automatic resizing.