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

Method testHistogramPoissonML

tests/analysis/fit/FitTest.cpp:4065–4110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4063}
4064
4065void FitTest::testHistogramPoissonML() {
4066 Spreadsheet spreadsheet(QStringLiteral("test"), false);
4067 AsciiFilter filter;
4068
4069 const QString& fileName = QFINDTESTDATA(QLatin1String("data/Poisson.dat"));
4070
4071 auto properties = filter.properties();
4072 properties.headerEnabled = false;
4073 filter.setProperties(properties);
4074 filter.readDataFromFile(fileName, &spreadsheet, AbstractFileFilter::ImportMode::Replace);
4075
4076 QCOMPARE(spreadsheet.rowCount(), 100);
4077 QCOMPARE(spreadsheet.columnCount(), 1);
4078
4079 Worksheet worksheet(QStringLiteral("test"), false);
4080 auto* plot = new CartesianPlot(QStringLiteral("plot"));
4081 worksheet.addChild(plot);
4082
4083 auto* hist = new Histogram(QStringLiteral("Histogram"));
4084 plot->addChild(hist);
4085 hist->setDataColumn(spreadsheet.column(0));
4086
4087 // Do the fit
4088 plot->addHistogramFit(hist, nsl_sf_stats_poisson);
4089
4090 auto fit = dynamic_cast<XYFitCurve*>(plot->child<XYFitCurve>(0));
4091 QVERIFY(fit != nullptr);
4092
4093 QCOMPARE(fit->name(), i18n("Distribution Fit to '%1'", hist->name()));
4094 // get results
4095 const XYFitCurve::FitResult& fitResult = fit->fitResult();
4096
4097 QCOMPARE(fitResult.available, true);
4098 QCOMPARE(fitResult.valid, true);
4099
4100 WARN(std::setprecision(15) << fitResult.paramValues.at(0));
4101 QCOMPARE(fitResult.paramValues.at(0), 150.);
4102 WARN(std::setprecision(15) << fitResult.paramValues.at(1));
4103 QCOMPARE(fitResult.paramValues.at(1), 9.55);
4104 WARN(std::setprecision(15) << fitResult.errorValues.at(1));
4105 QCOMPARE(fitResult.errorValues.at(1), 0.309030742807249);
4106 WARN(std::setprecision(15) << fitResult.paramValues.at(1) - fitResult.marginValues.at(1));
4107 QCOMPARE(fitResult.paramValues.at(1) - fitResult.marginValues.at(1), 8.95383732390823);
4108 WARN(std::setprecision(15) << fitResult.paramValues.at(1) + fitResult.margin2Values.at(1));
4109 QCOMPARE(fitResult.paramValues.at(1) + fitResult.margin2Values.at(1), 10.1754213697868);
4110}
4111
4112void FitTest::testHistogramBinomialML() {
4113 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