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

Method testHistogramGaussianML

tests/analysis/fit/FitTest.cpp:3831–3885  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3829}
3830
3831void FitTest::testHistogramGaussianML() {
3832 Spreadsheet spreadsheet(QStringLiteral("test"), false);
3833 AsciiFilter filter;
3834
3835 const QString& fileName = QFINDTESTDATA(QLatin1String("data/Gaussian.dat"));
3836
3837 auto properties = filter.properties();
3838 properties.headerEnabled = false;
3839 filter.setProperties(properties);
3840 filter.readDataFromFile(fileName, &spreadsheet, AbstractFileFilter::ImportMode::Replace);
3841
3842 QCOMPARE(spreadsheet.rowCount(), 1000);
3843 QCOMPARE(spreadsheet.columnCount(), 1);
3844
3845 Worksheet worksheet(QStringLiteral("test"), false);
3846 auto* plot = new CartesianPlot(QStringLiteral("plot"));
3847 worksheet.addChild(plot);
3848
3849 auto* hist = new Histogram(QStringLiteral("Histogram"));
3850 plot->addChild(hist);
3851 hist->setDataColumn(spreadsheet.column(0));
3852
3853 // Do the fit
3854 plot->addHistogramFit(hist, nsl_sf_stats_gaussian);
3855
3856 auto fit = dynamic_cast<XYFitCurve*>(plot->child<XYFitCurve>(0));
3857 QVERIFY(fit != nullptr);
3858
3859 QCOMPARE(fit->name(), i18n("Distribution Fit to '%1'", hist->name()));
3860 // get results
3861 const XYFitCurve::FitResult& fitResult = fit->fitResult();
3862
3863 QCOMPARE(fitResult.available, true);
3864 QCOMPARE(fitResult.valid, true);
3865
3866 WARN(std::setprecision(15) << fitResult.paramValues.at(0));
3867 QCOMPARE(fitResult.paramValues.at(0), 210.380459328);
3868 WARN(std::setprecision(15) << fitResult.paramValues.at(1));
3869 QCOMPARE(fitResult.paramValues.at(1), 0.999776858937);
3870 WARN(std::setprecision(15) << fitResult.errorValues.at(1));
3871 QCOMPARE(fitResult.errorValues.at(1), 0.0223507017166885);
3872 WARN(std::setprecision(15) << fitResult.paramValues.at(1) - fitResult.marginValues.at(1));
3873 QCOMPARE(fitResult.paramValues.at(1) - fitResult.marginValues.at(1), 0.955917043549699);
3874 WARN(std::setprecision(15) << fitResult.paramValues.at(1) + fitResult.marginValues.at(1));
3875 QCOMPARE(fitResult.paramValues.at(1) + fitResult.marginValues.at(1), 1.0436366743251);
3876
3877 WARN(std::setprecision(15) << fitResult.paramValues.at(2));
3878 QCOMPARE(fitResult.paramValues.at(2), -0.0294045302042);
3879 WARN(std::setprecision(15) << fitResult.errorValues.at(2));
3880 QCOMPARE(fitResult.errorValues.at(2), 0.0316157202617);
3881 WARN(std::setprecision(15) << fitResult.paramValues.at(2) - fitResult.marginValues.at(2));
3882 QCOMPARE(fitResult.paramValues.at(2) - fitResult.marginValues.at(2), -0.0914455198610062);
3883 WARN(std::setprecision(15) << fitResult.paramValues.at(2) + fitResult.marginValues.at(2));
3884 QCOMPARE(fitResult.paramValues.at(2) + fitResult.marginValues.at(2), 0.0326364594526431);
3885}
3886
3887void FitTest::testHistogramExponentialML() {
3888 Spreadsheet spreadsheet(QStringLiteral("test"), false);

Callers

nothing calls this directly

Calls 10

setPropertiesMethod · 0.80
addHistogramFitMethod · 0.80
propertiesMethod · 0.45
readDataFromFileMethod · 0.45
rowCountMethod · 0.45
columnCountMethod · 0.45
addChildMethod · 0.45
setDataColumnMethod · 0.45
columnMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected