Python中的分位数函数

dsa*_*ton 6 python numpy scipy quantile

我在Python中找到众所周知的概率分布的分位数函数时遇到了问题,它们是否存在?特别是,是否存在反正态分布函数?我在Numpy或Scipy都找不到任何东西.

dbo*_*ouz 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
Run Code Online (Sandbox Code Playgroud)