[SciPy-User] Asymmetric peak fitting

Matt Newville newville at cars.uchicago.edu
Thu Mar 19 15:01:57 EDT 2015


Hi Jonathon,


On Thu, Mar 19, 2015 at 11:02 AM, jkhilmer at chemistry.montana.edu <
jkhilmer at chemistry.montana.edu> wrote:

>
> Ok, now I have a problem. In the attached script I try to fit some example
>> experimental data I have. The peak is actually a numerical derivative of a
>> step function - this is why the values are so large. I tried different
>> models, all except the ExponentialGaussianModel can handle the fit pretty
>> well using the automatically guessed parameters. I don't really understand
>> why. Is there something I'm missing here?
>>
>
> It might not be your script.  I can't reproduce the figure on Wikipedia (
> http://en.wikipedia.org/wiki/File:EMG_Distribution_PDF.png) using the
> lmfit model.  Specifically, cases with sigma != 1.0 don't seem right.
>
> Jonathan
>

Hmm, not sure what you're seeing.  From the link you give, this script

#!/usr/bin/env python
from numpy import linspace
import matplotlib.pyplot as plt
from lmfit.lineshapes import expgaussian

x      = linspace(-4, 6, 101)
red    =  expgaussian(x, amplitude=1, center= 0.0, sigma=1.0, gamma=1.0)
green  =  expgaussian(x, amplitude=1, center=-2.0, sigma=1.0, gamma=1.0)
blue   =  expgaussian(x, amplitude=1, center= 0.0, sigma=3.0, gamma=1.0)
yellow =  expgaussian(x, amplitude=1, center=-3.0, sigma=1.0, gamma=0.25)

plt.plot(x, red, 'r-')
plt.plot(x, green, 'g-')
plt.plot(x, blue, 'b-')
plt.plot(x, yellow, 'y-')
plt.savefig('test_expgauss.png')
plt.show()
#########################################

gives a plot that looks pretty similar to the one at the wikipedia page
(except for the nice labels):

[image: Inline image 2]


Do you see something different?  If so, what do you see?
Cheers,

--Matt Newville
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20150319/4cec0791/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_expgauss.png
Type: image/png
Size: 53745 bytes
Desc: not available
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20150319/4cec0791/attachment.png>


More information about the SciPy-User mailing list