Python 中数据列表的概率密度

问题描述 投票:0回答:1

我有一个数据列表。我在列表中的值是 0

我尝试过 plt.hist 但它在 y 轴上给了我奇怪的数字。就像 80,000 这是频率。

python matplotlib scipy probability-density probability-distribution
1个回答
0
投票

这是一个 MWE,可以在不知道您的数据源是什么样子以及您尝试使用什么 pdf 的情况下生成类似图像引用的内容。

import matplotlib.pyplot as plt
import scipy.stats as st
import numpy as np

x = np.linspace(0,1,500)

alpha = [0.01,1,5,10,20]
beta = [0.05,3,2.5,3.5,5]

fig, ax = plt.subplots(figsize=(9,7))

for params in zip(alpha,beta):
    ypdf = st.beta.pdf(x,params[0],params[1])
    label = r'$\alpha$='+str(params[0])+','+r'$\beta$='+str(params[1])
    ax.plot(x,ypdf,label=label,linewidth=2)

ax.grid()
ax.legend(fontsize=14)

以上将产生以下情节:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.