| 3934 | } |
| 3935 | |
| 3936 | void FitTest::testHistogramLaplaceML() { |
| 3937 | Spreadsheet spreadsheet(QStringLiteral("test"), false); |
| 3938 | AsciiFilter filter; |
| 3939 | |
| 3940 | const QString& fileName = QFINDTESTDATA(QLatin1String("data/Laplace.dat")); |
| 3941 | |
| 3942 | auto properties = filter.properties(); |
| 3943 | properties.headerEnabled = false; |
| 3944 | filter.setProperties(properties); |
| 3945 | filter.readDataFromFile(fileName, &spreadsheet, AbstractFileFilter::ImportMode::Replace); |
| 3946 | |
| 3947 | QCOMPARE(spreadsheet.rowCount(), 100); |
| 3948 | QCOMPARE(spreadsheet.columnCount(), 1); |
| 3949 | |
| 3950 | Worksheet worksheet(QStringLiteral("test"), false); |
| 3951 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 3952 | worksheet.addChild(plot); |
| 3953 | |
| 3954 | auto* hist = new Histogram(QStringLiteral("Histogram")); |
| 3955 | plot->addChild(hist); |
| 3956 | hist->setDataColumn(spreadsheet.column(0)); |
| 3957 | |
| 3958 | // Do the fit |
| 3959 | plot->addHistogramFit(hist, nsl_sf_stats_laplace); |
| 3960 | |
| 3961 | auto fit = dynamic_cast<XYFitCurve*>(plot->child<XYFitCurve>(0)); |
| 3962 | QVERIFY(fit != nullptr); |
| 3963 | |
| 3964 | QCOMPARE(fit->name(), i18n("Distribution Fit to '%1'", hist->name())); |
| 3965 | // get results |
| 3966 | const XYFitCurve::FitResult& fitResult = fit->fitResult(); |
| 3967 | |
| 3968 | QCOMPARE(fitResult.available, true); |
| 3969 | QCOMPARE(fitResult.valid, true); |
| 3970 | |
| 3971 | WARN(std::setprecision(15) << fitResult.paramValues.at(0)); |
| 3972 | QCOMPARE(fitResult.paramValues.at(0), 145.64147805241); |
| 3973 | WARN(std::setprecision(15) << fitResult.paramValues.at(1)); |
| 3974 | QCOMPARE(fitResult.paramValues.at(1), 1.99538835213796); |
| 3975 | WARN(std::setprecision(15) << fitResult.paramValues.at(2)); |
| 3976 | QCOMPARE(fitResult.paramValues.at(2), 4.95890340967321); |
| 3977 | } |
| 3978 | |
| 3979 | void FitTest::testHistogramCauchyML() { |
| 3980 | Spreadsheet spreadsheet(QStringLiteral("test"), false); |
nothing calls this directly
no test coverage detected