mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 22:00:28 +01:00
[apps/reg] Prevent fitting when data not suitable
This commit is contained in:
@@ -11,7 +11,17 @@ using namespace Shared;
|
||||
namespace Regression {
|
||||
|
||||
void Model::fit(Store * store, int series, double * modelCoefficients, Poincare::Context * context) {
|
||||
fitLevenbergMarquardt(store, series, modelCoefficients, context);
|
||||
if (dataSuitableForFit(store, series)) {
|
||||
fitLevenbergMarquardt(store, series, modelCoefficients, context);
|
||||
} else {
|
||||
for (int i = 0; i < numberOfCoefficients(); i++) {
|
||||
modelCoefficients[i] = NAN; //TODO undef /inf ?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Model::dataSuitableForFit(Store * store, int series) const {
|
||||
return !store->seriesIsEmpty(series) && !std::isinf(store->slope(series)) && !std::isnan(store->slope(series));
|
||||
}
|
||||
|
||||
void Model::fitLevenbergMarquardt(Store * store, int series, double * modelCoefficients, Context * context) {
|
||||
|
||||
Reference in New Issue
Block a user