27#ifndef quantlib_linear_least_squares_regression_hpp
28#define quantlib_linear_least_squares_regression_hpp
38 template <
class Container>
51 template <
class xContainer>
58 if constexpr (std::is_arithmetic_v<ArgumentType>) {
61 Size m = x.begin()->size();
62 for (
Size i = 0; i < m; ++i)
79 template <
class xContainer,
class yContainer>
81 const yContainer&
y,
Real intercept = 1.0);
83 template <
class xContainer,
class yContainer,
class vContainer>
85 const yContainer&
y,
const vContainer &
v);
89 template <
class xContainer,
class yContainer>
inline
91 const yContainer&
y,
Real intercept)
93 details::LinearFcts<xContainer>(x, intercept).fcts()) {
96 template <
class xContainer,
class yContainer,
class vContainer>
inline
106 template <
class ArgumentType = Real>
110 const std::vector<ArgumentType> & x,
111 const std::vector<Real> &
y,
112 const std::vector<std::function<
Real(ArgumentType)> > &
v)
general linear least squares regression
LinearLeastSquaresRegression(const std::vector< ArgumentType > &x, const std::vector< Real > &y, const std::vector< std::function< Real(ArgumentType)> > &v)
LinearRegression(const xContainer &x, const yContainer &y, Real intercept=1.0)
linear regression y_i = a_0 + a_1*x_0 +..+a_n*x_{n-1} + eps
Real operator()(const Container &x) const
xContainer::value_type ArgumentType
LinearFcts(const xContainer &x, Real intercept)
const std::vector< std::function< Real(ArgumentType)> > & fcts()
std::vector< std::function< Real(ArgumentType)> > v
Maps function, bind and cref to either the boost or std implementation.
general linear least square regression
std::size_t Size
size of a container
ext::shared_ptr< BlackVolTermStructure > v