| 324 | } |
| 325 | |
| 326 | void FitTest::testLinearNoInt2_2() { |
| 327 | // NIST data for NoInt2 dataset |
| 328 | QVector<int> xData = {4, 5, 6}; |
| 329 | QVector<int> yData = {3, 4, 4}; |
| 330 | |
| 331 | // data source columns |
| 332 | Column xDataColumn(QStringLiteral("x"), AbstractColumn::ColumnMode::Integer); |
| 333 | xDataColumn.replaceInteger(0, xData); |
| 334 | |
| 335 | Column yDataColumn(QStringLiteral("y"), AbstractColumn::ColumnMode::Integer); |
| 336 | yDataColumn.replaceInteger(0, yData); |
| 337 | |
| 338 | XYFitCurve fitCurve(QStringLiteral("fit")); |
| 339 | fitCurve.setXDataColumn(&xDataColumn); |
| 340 | fitCurve.setYDataColumn(&yDataColumn); |
| 341 | |
| 342 | // prepare the fit |
| 343 | XYFitCurve::FitData fitData = fitCurve.fitData(); |
| 344 | fitData.modelCategory = nsl_fit_model_basic; |
| 345 | fitData.modelType = nsl_fit_model_polynomial; |
| 346 | fitData.degree = 1; |
| 347 | XYFitCurve::initFitData(fitData); |
| 348 | fitData.paramStartValues[0] = 0; |
| 349 | fitData.paramFixed[0] = true; |
| 350 | fitCurve.setFitData(fitData); |
| 351 | |
| 352 | // perform the fit |
| 353 | fitCurve.recalculate(); |
| 354 | const XYFitCurve::FitResult& fitResult = fitCurve.fitResult(); |
| 355 | |
| 356 | // check the results |
| 357 | QCOMPARE(fitResult.available, true); |
| 358 | QCOMPARE(fitResult.valid, true); |
| 359 | |
| 360 | const int np = fitData.paramNames.size(); |
| 361 | QCOMPARE(np, 2); |
| 362 | |
| 363 | QCOMPARE(fitResult.paramValues.at(0), 0.); |
| 364 | QCOMPARE(fitResult.paramValues.at(1), 0.727272727272727); |
| 365 | QCOMPARE(fitResult.errorValues.at(1), 0.420827318078432e-1); |
| 366 | |
| 367 | QCOMPARE(fitResult.rsd, 0.369274472937998); |
| 368 | QCOMPARE(fitResult.sse, 0.272727272727273); |
| 369 | QCOMPARE(fitResult.rms, 0.136363636363636); |
| 370 | QCOMPARE(fitResult.rsquare, 0.993348115299335); |
| 371 | DEBUG(std::setprecision(15) << fitResult.fdist_F); // result: 300.666666666667 |
| 372 | QCOMPARE(fitResult.fdist_F, 298.666666666667); |
| 373 | } |
| 374 | |
| 375 | void FitTest::testLinearFilip() { |
| 376 | // NIST data for Filip dataset |
nothing calls this directly
no test coverage detected