简体   繁体   中英

Fitting a mixture of lognormal distributions in Python

scipy provides a nice way to fit a single lognormal distribution. I see that scikit-learn has the ability to fit normal (Gaussian) mixtures. Is there a straightforward way to fit a mixture of two lognormal distributions? If not, is there a superior approach to optimizing the parameters "by hand" either directly with scipy.optimize or by defining the mixture distribution as a subclass of scipy.stats.rv_continuous ?

I stumbled across this and it worked great for me:

https://pomegranate.readthedocs.io/en/latest/GeneralMixtureModel.html

example usage:

from pomegranate import *

x = np.array(df['foo']).reshape(-1, 1)

model = GeneralMixtureModel.from_samples(LogNormalDistribution, n_components=2, X=x)
model.fit(x)
pomegranate_clusters = model.predict(x)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM