【发布时间】:2017-04-06 23:08:50
【问题描述】:
我正在尝试使用 fastKDE 包 (https://pypi.python.org/pypi/fastkde/1.0.8) 来查找 2D 图中某个点的 KDE。但是,我想知道超出数据点限制的 KDE,但不知道如何做到这一点。
使用上面链接的网站上列出的代码;
#!python
import numpy as np
from fastkde import fastKDE
import pylab as PP
#Generate two random variables dataset (representing 100000 pairs of datapoints)
N = 2e5
var1 = 50*np.random.normal(size=N) + 0.1
var2 = 0.01*np.random.normal(size=N) - 300
#Do the self-consistent density estimate
myPDF,axes = fastKDE.pdf(var1,var2)
#Extract the axes from the axis list
v1,v2 = axes
#Plot contours of the PDF should be a set of concentric ellipsoids centered on
#(0.1, -300) Comparitively, the y axis range should be tiny and the x axis range
#should be large
PP.contour(v1,v2,myPDF)
PP.show()
我能够找到数据范围内任何点的 KDE,但是我如何找到点 (0,300) 的 KDE,而不必将它包含到 var1 和 var2 中。我不想用这个数据点计算 KDE,我想知道那个时候的 KDE。
我想我真正想做的是给 fastKDE 一个数据的直方图,这样我就可以自己设置它的轴了。我只是不知道这是否可能?
干杯
【问题讨论】:
标签: python kernel-density