Calculated Parameters Wrong in MDFit

While trying to fit a synthetically created MDHistoWorkspace with a certain function with any of the available minimizers, none of them could fit it correctly. In fact, all of them returned the same parameter value. However, that was a parameter that does not adjust at all to the data.

I could not find any way to upload the data file used. The generating script is too long and non-image files cannot be uploaded.

The fitting function is 1/3.1415692*(Dy^2)/(DD*y^4+x^2) where D is a parameter and the data has been created with D = 1. Even giving D = 1 as the initial parameter value it cannot fit correctly the data. I have seen that it has been reported a bug on the generation of the Calc/Diff workspace (‘Calculated fit curves wrong in multi fit’). However, in this case, the parameter itself is wrong, since the returned value is D=0.13786 for all the minimizers, which is really far from the real value (D=1).

The fitting call that was used is the following:

Fit(Function='name = UserFunctionMD, Formula = 1/3.1415692*(D*y^2)/(D*D*y^4+x^2), D=1.', InputWorkspace='sqw', MaxIterations=50000, Minimizer='Levenberg-MarquardtMD', Output='sqw_output', OutputCompositeMembers=True) 

The original data looks like this:

While the fitted Workspace is quite different:

Platforms affected

It seems to affect Linux as well as Windows, at least.

I had a look at MDworkspace fitting nearly a year ago. There was an issue with normalisation to pixel volume, as well as very sparse documentation (for example CreateMDHistoWorkspace isn’t mentioned under Concepts - MDHistoWorkspace) and no Python fit function API yet. See Data normalization for MDWorkspaces · Issue #16736 · mantidproject/mantid · GitHub (still open, still behaves as it did then).