MCPcopy Create free account
hub / github.com/KDE/labplot / testLinearWampler1

Method testLinearWampler1

tests/analysis/fit/FitTest.cpp:482–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482void FitTest::testLinearWampler1() {
483 // NIST data for Wampler1 dataset
484 QVector<int> xData = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
485 QVector<int> yData = {1, 6, 63, 364, 1365, 3906, 9331, 19608, 37449, 66430, 111111,
486 177156, 271453, 402234, 579195, 813616, 1118481, 1508598, 2000719, 2613660, 3368421};
487
488 // data source columns
489 Column xDataColumn(QStringLiteral("x"), AbstractColumn::ColumnMode::Integer);
490 xDataColumn.replaceInteger(0, xData);
491
492 Column yDataColumn(QStringLiteral("y"), AbstractColumn::ColumnMode::Integer);
493 yDataColumn.replaceInteger(0, yData);
494
495 XYFitCurve fitCurve(QStringLiteral("fit"));
496 fitCurve.setXDataColumn(&xDataColumn);
497 fitCurve.setYDataColumn(&yDataColumn);
498
499 // prepare the fit
500 XYFitCurve::FitData fitData = fitCurve.fitData();
501 fitData.modelCategory = nsl_fit_model_basic;
502 fitData.modelType = nsl_fit_model_polynomial;
503 fitData.degree = 5;
504 XYFitCurve::initFitData(fitData);
505 fitCurve.setFitData(fitData);
506
507 // perform the fit
508 fitCurve.recalculate();
509 const XYFitCurve::FitResult& fitResult = fitCurve.fitResult();
510
511 // check the results
512 QCOMPARE(fitResult.available, true);
513 QCOMPARE(fitResult.valid, true);
514
515 const int np = fitData.paramNames.size();
516 QCOMPARE(np, 6);
517
518 for (int i = 0; i < np; i++) {
519 const double paramValue = fitResult.paramValues.at(i);
520 const double errorValue = fitResult.errorValues.at(i);
521 QCOMPARE(paramValue, 1.0);
522 QCOMPARE(errorValue, 0.0);
523 }
524
525 QCOMPARE(fitResult.rsd, 0.0);
526 QCOMPARE(fitResult.rsquare, 1.0);
527 QCOMPARE(fitResult.sse, 0.0);
528 QCOMPARE(fitResult.rms, 0.0);
529 QVERIFY(std::isinf(fitResult.fdist_F));
530}
531
532void FitTest::testLinearWampler1_custom() {
533 // NIST data for Wampler1 dataset

Callers

nothing calls this directly

Calls 6

setXDataColumnMethod · 0.80
setYDataColumnMethod · 0.80
replaceIntegerMethod · 0.45
setFitDataMethod · 0.45
recalculateMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected