我有一个一维数组,我已经用scipy.stats.gaussian_kde得到了pdf。现在我想计算每个特定数据点的积分,我的代码如下。这有意义吗?如果没有,正确的解决方案是什么?顺便问一下,我该如何可视化pdf和积分函数?谢谢
X=np.array([0.21,0.21,0.21,0.28,0.30,0.30,0.24,0.22,0.19,0.20,0.18,0.23,0.20,0.12,0.14,0.13,0.18,0.15,0.13,0.11,0.12,0.11,0.10,0.13,0.03,0.07,0.17,0.16])
kde=scipy.stats.gaussian_kde(X, bw_method=None, weights=None)
for x in X:
print(kde.integrate_box_1d(-np.inf, x))
1条答案
按热度按时间83qze16e1#
为了绘制
kde
,你需要创建一个x值的密集数组。给定点的积分可以通过散点图绘制。