我正在尝试在 Python 中使用 scypi 定义帕累托分布。我有 alpha 和 xm 的值,就像它们在分布的经典定义中一样,例如在维基百科中:https://en.wikipedia.org/wiki/Pareto_distribution 假设我想要 alpha = 4 和 xm = 3。 如何使用这些参数初始化 scipy.stats.pareto?
import scipy.stats as sts
pareto_alpha = 4
pareto_xm = 3
pareto_rv = sts.pareto(???)
这里是 pareto 函数的文档页面 https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.pareto.html#scipy.stats.pareto 我在那里找不到构造函数的明确描述。
请您参考如下方法:
您可以像这样绘制不同 b 值(形状参数)的 pdf:
import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import pareto
xm = 1 # scale
alphas = [1, 2, 3] # shape parameters
x = np.linspace(0, 5, 1000)
output = np.array([pareto.pdf(x, scale = xm, b = a) for a in alphas])
plt.plot(x, output.T)
plt.show()
