Python 中的分位数函数

9

我在Python中找不到一些著名概率分布的分位数函数,它们存在吗?特别是,是否存在逆正态分布函数?我在Numpy和Scipy中都没有找到任何东西。


2
https://dev59.com/pGAf5IYBdhLWcg3wZB-u - behzad.nouri
2
...和https://dev59.com/ymIj5IYBdhLWcg3wGRmN#20627638 - Warren Weckesser
2个回答

6

查看scipy.stats中任何分布类的.ppf()方法。这相当于分位数函数(又称为百分点函数或反CDF)

以scipy.stats中的指数分布为例:

# analysis libs
import scipy
import numpy as np
# plotting libs
import matplotlib as mpl
import matplotlib.pyplot as plt

# Example with the exponential distribution
c = 0
lamb = 2

# Create a frozen exponential distribution instance with specified parameters
exp_obj = scipy.stats.expon(c,1/float(lamb))

x_in = np.linspace(0,1,200) # 200 numbers in [0,1], input for ppf()
y_out = exp_obj.ppf(x_in)
plt.plot(x_in,y_out) # graphically check the results of the inverse CDF

0

这似乎是新的,但我发现了关于numpy和分位数的this。也许你可以看一下(未经测试)


2
这提供了一组观察值的经验分位数,而不是海报所要求的理论分布的确切分位数。它是numpy的新功能,但提供与函数“np.percentile”相同的功能。 - user2699

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接