SiLab-Bonn / pylandau

Simple Landau distribution definitions to be used in Python.
GNU Lesser General Public License v2.1
20 stars 5 forks source link

Oscillations in pylandau.langau function #5

Closed fmu984 closed 8 years ago

fmu984 commented 8 years ago

Dear David, according to your renaming I changed the imports in my python scripts to: import pylandau using optimize.curve_fit(pylandau.landau results in a strange fit - anyway but not a landau. Please have a look at the red curve. The green is langau which looks fine.

figure_1

DavidLP commented 8 years ago

Thank you very much for your bug report. So far oscillations were only observed when the Langaus function was used and the eta / sigma ration was too large (see issue: https://github.com/SiLab-Bonn/pyLandau/issues/1). To see this without convolution is weird. Can you tell me the fit results (mu, eta, A) so that I can try to reproduce the error?

fmu984 commented 8 years ago

Fixed by using more appropriate parameters. Indeed it is the Langau, not Landau.

DavidLP commented 8 years ago

That's the difficulty with convolution and and fitting that can create an oscillating solution. To make the fit more stable it is usually good to restrict the parameter range by setting bounds. This is possible with scipy with the bounds parameter:

curve_fit(func, xdata, ydata, bounds=(0, [3., 2., 1.]))