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

Method testHistogramLognormalML

tests/analysis/fit/FitTest.cpp:4022–4063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4020}
4021
4022void FitTest::testHistogramLognormalML() {
4023 Spreadsheet spreadsheet(QStringLiteral("test"), false);
4024 AsciiFilter filter;
4025
4026 const QString& fileName = QFINDTESTDATA(QLatin1String("data/Lognormal.dat"));
4027
4028 auto properties = filter.properties();
4029 properties.headerEnabled = false;
4030 filter.setProperties(properties);
4031 filter.readDataFromFile(fileName, &spreadsheet, AbstractFileFilter::ImportMode::Replace);
4032
4033 QCOMPARE(spreadsheet.rowCount(), 1000);
4034 QCOMPARE(spreadsheet.columnCount(), 1);
4035
4036 Worksheet worksheet(QStringLiteral("test"), false);
4037 auto* plot = new CartesianPlot(QStringLiteral("plot"));
4038 worksheet.addChild(plot);
4039
4040 auto* hist = new Histogram(QStringLiteral("Histogram"));
4041 plot->addChild(hist);
4042 hist->setDataColumn(spreadsheet.column(0));
4043
4044 // Do the fit
4045 plot->addHistogramFit(hist, nsl_sf_stats_lognormal);
4046
4047 auto fit = dynamic_cast<XYFitCurve*>(plot->child<XYFitCurve>(0));
4048 QVERIFY(fit != nullptr);
4049
4050 QCOMPARE(fit->name(), i18n("Distribution Fit to '%1'", hist->name()));
4051 // get results
4052 const XYFitCurve::FitResult& fitResult = fit->fitResult();
4053
4054 QCOMPARE(fitResult.available, true);
4055 QCOMPARE(fitResult.valid, true);
4056
4057 WARN(std::setprecision(15) << fitResult.paramValues.at(0));
4058 QCOMPARE(fitResult.paramValues.at(0), 4714813.91602);
4059 WARN(std::setprecision(15) << fitResult.paramValues.at(1));
4060 QCOMPARE(fitResult.paramValues.at(1), 2.07876791650682);
4061 WARN(std::setprecision(15) << fitResult.paramValues.at(2));
4062 QCOMPARE(fitResult.paramValues.at(2), 5.01070949852617);
4063}
4064
4065void FitTest::testHistogramPoissonML() {
4066 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