【问题标题】:equivalent of Matlab's gaminv in python相当于matlab在python中的gaminv
【发布时间】:2016-10-14 03:51:53
【问题描述】:

我想用 Python 翻译以下 Matlab 代码:

 tau=40 %scale parameter
 a=3 %shape parameter
 t = gaminv(0.90,a,tau);

代码返回 t = 212.8928。我试过了:

 import scipy.stats.distributions as dist
 tau=40
 a=3
 t = dist.invgamma.cdf(90, a, scale = tau)

但 python 代码不会返回相同的 t 值。我做错了吗?

【问题讨论】:

    标签: python matlab scipy gamma-distribution


    【解决方案1】:

    您想要scipy.stats.gammappf(“百分比点函数”,它是CDF 或分位数函数的逆函数的一个不太常见的名称)方法:

    In [27]: from scipy.stats import gamma
    
    In [28]: gamma.ppf(0.9, 3, scale=40)
    Out[28]: 212.8928135133684
    

    另见How to calculate the inverse of the normal cumulative distribution function in python?;那里的分布不同,但基本上是同一个问题。

    invgamma 是一个不同的分布。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-23
      • 2023-03-17
      • 1970-01-01
      • 2010-12-16
      相关资源
      最近更新 更多