有没有办法使用 Scipy 自动估计 t 分布的最佳自由度?

Is there a way to automatically estimate the best degree of freedoms for a t-distribution using Scipy?

很多函数只是要求您输入自由度以拟合分布和 return 其他项目。但是,我想要一个像 R 的 fitdistr 这样的函数,它可以估计均值、比例参数和 df。我的最终目标是使用最佳估计的 df 获得 t 分数。

使用 Scipy,您可以使用与 t 分布相关的拟合函数 class 来估计自由度、位置和尺度(有关详细信息,请参阅 here and here)。这使用最大似然估计参数,例如 R. E.G. 中 MASS 的 fitdistr 函数。

from scipy import stats
import numpy as np
np.random.seed(2015)

x = [ stats.t.rvs(9) for i in range(250)]
stats.t.fit(x)

这给出了 df = 5.63、位置 = 0.00 和比例 = 0.85 的估计值 需要注意的一点是,如果您还估计比例和位置,则估计的自由度拟合可能不会很好。当您最大化似然函数时,您可能只会达到局部最优,所以也许可以标准化您的数据?