Python中的分位数函数

2024-06-03 12:26:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Python中很难找到已知概率分布的分位数函数,它们存在吗?特别是,是否存在逆正态分布函数?我在纽比和希比都找不到任何东西。


Tags: 函数位数概率分布正态分布
2条回答

检查scipy.stats中任何分发类的.ppf()方法。 这相当于分位数函数(或者称为百分点函数或逆CDF)

来自scipy.stats的exponential distribution示例:

# 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

它看起来很新,但我发现了关于原子核和分位数的this。也许你可以看看(不测试)

相关问题 更多 >