# [SciPy-User] Using scipy to fit a bimodal distribution

2 messages
Open this post in threaded view
|

## [SciPy-User] Using scipy to fit a bimodal distribution

Hi Folks,

I have some data, which is bimodally distributed.

The initial part of the data(in red, in the figure below), seems to be exponentially distributed and the latter part(in blue, in the figure below), seems to be a gamma distribution.

See image below (& attached) :

​
What scipy function, i could use to fit this data, knowing that, the first mode is exponential, and the latter, seems to be gamma.
If its not possible to do it using scipy, is there another library/module i could use to do this ?

Thanks a ton,
ashish

--

# - Jeff Hammerbacher (early fb engineer)

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

Open this post in threaded view
|

## Re: Using scipy to fit a bimodal distribution

Hi Ashish,

I can recommend lmfit: https://lmfit.github.io It's and additional module, so you'll need to install it, but it's worth it. It's well documented, easy to use and provides the possibility of creating composite models (https://lmfit.github.io/lmfit-py/model.html#composite-models-adding-or-multiplying-models). I use it whenever I need to fit a double peak. It will also work with two different distributions.

Cheers,

Paweł

2018-03-16 8:14 GMT+01:00 spiff007 :
Hi Folks,

I have some data, which is bimodally distributed.

The initial part of the data(in red, in the figure below), seems to be exponentially distributed and the latter part(in blue, in the figure below), seems to be a gamma distribution.

See image below (& attached) :

​
What scipy function, i could use to fit this data, knowing that, the first mode is exponential, and the latter, seems to be gamma.
If its not possible to do it using scipy, is there another library/module i could use to do this ?

Thanks a ton,
ashish

--

# - Jeff Hammerbacher (early fb engineer)

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user

_______________________________________________
SciPy-User mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/scipy-user