在Python中计算分布的对数似然 [英] Calculating loglikelihood of distributions in Python
本文介绍了在Python中计算分布的对数似然的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
计算适合数据的任何分布的对数似然性的简单方法是什么?
推荐答案
OP解决方案.
Python有82个标准发行版,可以在此处和 scipy.stats.distributions
Python has 82 standard distributions which can be found here and in scipy.stats.distributions
假设您找到的参数使得概率密度函数(pdf)适合数据如下:
Suppose you find the parameters such that the probability density function(pdf) fits the data as follows:
dist = getattr(stats.stats, 'distribution name')
params = dist.fit(data)
然后,由于它是SciPy库中包含的标准发行版,因此可以通过以下方式非常容易地找到和使用pdf和logpdf:
Then since it is a standard distribution included in the SciPy library, the pdf and logpdf can be found and used very easily in the following way:
LLH = dist.logpdf(data,*params).sum()
请注意,这与此处定义的对数似然函数相对应.
这篇关于在Python中计算分布的对数似然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文