28 std::pair<double, double>
34 Assert(x.size() == y.size(),
35 ExcMessage(
"x and y are expected to have the same size"));
39 "at least two points are required for linear regression fit"));
41 double sum_1 = 0.0, sum_x = 0.0, sum_x2 = 0.0, sum_y = 0.0, sum_xy = 0.0;
43 for (
unsigned int i = 0; i < x.size(); ++i)
47 sum_x2 += x[i] * x[i];
49 sum_xy += x[i] * y[i];
61 invK.
vmult(X, B,
false);
63 return std::make_pair(X(1), X(0));
void vmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
void invert(const FullMatrix< number2 > &M)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcMessage(std::string arg1)
std::pair< double, double > linear_regression(const std::vector< double > &x, const std::vector< double > &y)