18 #include <deal.II/base/config.h> 20 #include <deal.II/fe/fe_series.h> 25 DEAL_II_NAMESPACE_OPEN
29 std::pair<double, double>
35 Assert(x.size() == y.size(),
36 ExcMessage(
"x and y are expected to have the same size"));
40 "at least two points are required for linear regression fit"));
42 double sum_1 = 0.0, sum_x = 0.0, sum_x2 = 0.0, sum_y = 0.0, sum_xy = 0.0;
44 for (
unsigned int i = 0; i < x.size(); i++)
48 sum_x2 += x[i] * x[i];
50 sum_xy += x[i] * y[i];
62 invK.
vmult(X, B,
false);
64 return std::make_pair(X(1), X(0));
68 DEAL_II_NAMESPACE_CLOSE
void vmult(Vector< number2 > &w, const Vector< number2 > &v, const bool adding=false) const
std::pair< double, double > linear_regression(const std::vector< double > &x, const std::vector< double > &y)
static ::ExceptionBase & ExcMessage(std::string arg1)
void invert(const FullMatrix< number2 > &M)
#define Assert(cond, exc)