mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/regression] Fix wrong proportional model fit
This commit is contained in:
@@ -27,10 +27,6 @@ double ProportionalModel::levelSet(double * modelCoefficients, double xMin, doub
|
||||
return y/a;
|
||||
}
|
||||
|
||||
void ProportionalModel::fit(Store * store, int series, double * modelCoefficients, Poincare::Context * context) {
|
||||
modelCoefficients[0] = store->slope(series);
|
||||
}
|
||||
|
||||
double ProportionalModel::partialDerivate(double * modelCoefficients, int derivateCoefficientIndex, double x) const {
|
||||
assert(derivateCoefficientIndex == 0);
|
||||
// Derivate: x
|
||||
|
||||
@@ -12,7 +12,6 @@ public:
|
||||
I18n::Message formulaMessage() const override { return I18n::Message::ProportionalRegressionFormula; }
|
||||
double evaluate(double * modelCoefficients, double x) const override;
|
||||
double levelSet(double * modelCoefficients, double xMin, double step, double xMax, double y, Poincare::Context * context) override;
|
||||
void fit(Store * store, int series, double * modelCoefficients, Poincare::Context * context) override;
|
||||
double partialDerivate(double * modelCoefficients, int derivateCoefficientIndex, double x) const override;
|
||||
int numberOfCoefficients() const override { return 1; }
|
||||
int bannerLinesCount() const override { return 2; }
|
||||
|
||||
@@ -50,6 +50,14 @@ QUIZ_CASE(proportional_regression) {
|
||||
assert_regression_is(x, y, 5, Model::Type::Proportional, coefficients);
|
||||
}
|
||||
|
||||
QUIZ_CASE(proportional_regression2) {
|
||||
constexpr int numberOfPoints = 4;
|
||||
double x[numberOfPoints] = {5.0, 2.0, 3.0, 4.0};
|
||||
double y[numberOfPoints] = {10.0, 6.0, 7.0, 8.0};
|
||||
double coefficients[] = {2.12963963};
|
||||
assert_regression_is(x, y, numberOfPoints, Model::Type::Proportional, coefficients);
|
||||
}
|
||||
|
||||
QUIZ_CASE(quadratic_regression) {
|
||||
double x[] = {-34.0, -12.0, 5.0, 86.0, -2.0};
|
||||
double y[] = {-8241.389, -1194.734, -59.163, - 46245.39, -71.774};
|
||||
|
||||
Reference in New Issue
Block a user