| 4020 | } |
| 4021 | |
| 4022 | void 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 | |
| 4065 | void FitTest::testHistogramPoissonML() { |
| 4066 | Spreadsheet spreadsheet(QStringLiteral("test"), false); |
nothing calls this directly
no test coverage detected