Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
LabPlot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Education
LabPlot
Commits
e37cefcd
Commit
e37cefcd
authored
Aug 03, 2020
by
Stefan Gerlach
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fit] Improve cases when chi^2 gets zero
parent
8ec710c6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
12 deletions
+19
-12
src/backend/worksheet/plots/cartesian/Axis.cpp
src/backend/worksheet/plots/cartesian/Axis.cpp
+0
-1
src/backend/worksheet/plots/cartesian/XYFitCurve.cpp
src/backend/worksheet/plots/cartesian/XYFitCurve.cpp
+18
-10
src/backend/worksheet/plots/cartesian/XYFitCurvePrivate.h
src/backend/worksheet/plots/cartesian/XYFitCurvePrivate.h
+1
-1
No files found.
src/backend/worksheet/plots/cartesian/Axis.cpp
View file @
e37cefcd
...
...
@@ -1426,7 +1426,6 @@ void AxisPrivate::retransformTickLabelStrings() {
if
(
suppressRetransform
)
return
;
//DEBUG("AxisPrivate::retransformTickLabelStrings()");
if
(
labelsAutoPrecision
)
{
//check, whether we need to increase the current precision
int
newPrecision
=
upperLabelsPrecision
(
labelsPrecision
);
...
...
src/backend/worksheet/plots/cartesian/XYFitCurve.cpp
View file @
e37cefcd
...
...
@@ -1824,14 +1824,20 @@ void XYFitCurvePrivate::recalculate() {
DEBUG
(
Q_FUNC_INFO
<<
", run fdfsolver_iterate"
);
status
=
gsl_multifit_fdfsolver_iterate
(
s
);
DEBUG
(
Q_FUNC_INFO
<<
", fdfsolver_iterate DONE"
);
writeSolverState
(
s
);
double
chi2
=
gsl_pow_2
(
gsl_blas_dnrm2
(
s
->
f
));
writeSolverState
(
s
,
chi2
);
if
(
status
)
{
DEBUG
(
Q_FUNC_INFO
<<
", iter "
<<
iter
<<
", status = "
<<
gsl_strerror
(
status
));
if
(
status
==
GSL_ETOLX
)
// change in the position vector falls below machine precision: no progress
status
=
GSL_SUCCESS
;
break
;
}
status
=
gsl_multifit_test_delta
(
s
->
dx
,
s
->
x
,
delta
,
delta
);
if
(
qFuzzyIsNull
(
chi2
))
{
DEBUG
(
Q_FUNC_INFO
<<
", chi^2 is zero! Finishing."
)
status
=
GSL_SUCCESS
;
}
else
{
status
=
gsl_multifit_test_delta
(
s
->
dx
,
s
->
x
,
delta
,
delta
);
}
DEBUG
(
Q_FUNC_INFO
<<
", iter "
<<
iter
<<
", test status = "
<<
gsl_strerror
(
status
));
}
while
(
status
==
GSL_CONTINUE
&&
iter
<
maxIters
);
...
...
@@ -1840,11 +1846,11 @@ void XYFitCurvePrivate::recalculate() {
DEBUG
(
Q_FUNC_INFO
<<
", Rerun fit with x errors"
);
unsigned
int
iter2
=
0
;
double
chi
sq
=
0
,
chisq
Old
=
0
;
double
chi
2
=
0
,
chi2
Old
=
0
;
double
*
fun
=
new
double
[
n
];
do
{
iter2
++
;
chi
sqOld
=
chisq
;
chi
2Old
=
chi2
;
//printf("iter2 = %d\n", iter2);
// calculate function from residuals
...
...
@@ -1935,8 +1941,8 @@ void XYFitCurvePrivate::recalculate() {
status
=
gsl_multifit_test_delta
(
s
->
dx
,
s
->
x
,
delta
,
delta
);
}
while
(
status
==
GSL_CONTINUE
&&
iter
<
maxIters
);
chi
sq
=
gsl_blas_dnrm2
(
s
->
f
);
}
while
(
iter2
<
maxIters
&&
fabs
(
chi
sq
-
chisq
Old
)
>
fitData
.
eps
);
chi
2
=
gsl_blas_dnrm2
(
s
->
f
);
}
while
(
iter2
<
maxIters
&&
fabs
(
chi
2
-
chi2
Old
)
>
fitData
.
eps
);
delete
[]
fun
;
}
...
...
@@ -2146,7 +2152,7 @@ void XYFitCurvePrivate::evaluate(bool preview) {
/*!
* writes out the current state of the solver \c s
*/
void
XYFitCurvePrivate
::
writeSolverState
(
gsl_multifit_fdfsolver
*
s
)
{
void
XYFitCurvePrivate
::
writeSolverState
(
gsl_multifit_fdfsolver
*
s
,
double
chi2
)
{
QString
state
;
//current parameter values, semicolon separated
...
...
@@ -2158,10 +2164,12 @@ void XYFitCurvePrivate::writeSolverState(gsl_multifit_fdfsolver* s) {
state
+=
QString
::
number
(
nsl_fit_map_bound
(
x
,
min
[
i
],
max
[
i
]))
+
'\t'
;
}
//current value of the chi2-function
state
+=
QString
::
number
(
gsl_pow_2
(
gsl_blas_dnrm2
(
s
->
f
)));
//current value of chi^2
if
(
isnan
(
chi2
))
chi2
=
gsl_pow_2
(
gsl_blas_dnrm2
(
s
->
f
));
state
+=
QString
::
number
(
chi2
);
state
+=
';'
;
DEBUG
(
Q_FUNC_INFO
<<
", chi
= "
<<
gsl_pow_2
(
gsl_blas_dnrm2
(
s
->
f
))
);
DEBUG
(
Q_FUNC_INFO
<<
", chi
^2 = "
<<
chi2
);
fitResult
.
solverOutput
+=
state
;
}
...
...
src/backend/worksheet/plots/cartesian/XYFitCurvePrivate.h
View file @
e37cefcd
...
...
@@ -63,7 +63,7 @@ public:
private:
void
prepareResultColumns
();
void
writeSolverState
(
gsl_multifit_fdfsolver
*
);
void
writeSolverState
(
gsl_multifit_fdfsolver
*
,
double
chi2
=
NAN
);
};
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment