python - `python` 中的加权高斯核密度估计

标签 python statistics scipy kernel-density

更新:scipy.stats.gaussian_kde 现在支持加权样本。参见 herehere了解详情。

目前无法使用 scipy.stats.gaussian_kde 根据 weighted samples 估计随机变量的密度.基于加权样本估计连续随机变量密度的方法有哪些?

最佳答案

都不是sklearn.neighbors.KernelDensity也不statsmodels.nonparametric似乎支持加权样本。我修改了 scipy.stats.gaussian_kde 以允许异构采样权重,并认为结果可能对其他人有用。示例如下所示。

example

ipython notebook 可以在这里找到:http://nbviewer.ipython.org/gist/tillahoffmann/f844bce2ec264c1c8cb5

实现细节

加权算术平均值为

weighted arithmetic mean

unbiased data covariance matrix然后由 unbiased covariance matrix

带宽可以通过 scottsilverman 规则来选择,就像在 scipy 中一样。然而,用于计算带宽的样本数是Kish's approximation for the effective sample size。 .

关于python - `python` 中的加权高斯核密度估计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27623919/

相关文章:

Python计算单行值的运行总和

python - ElementTree 中 findall 函数的无法解释的行为

c - 创建 : <Method Name> <Num of times called> for a particular project directory list 的脚本

machine-learning - 地理空间机器学习的人口抽样

python - 打开python最小化或隐藏的程序

Python:ModuleNotFoundError:没有名为 'Client' 的模块

java - 在 Java 中可视化数据

python - scipy stats kstest 针对 x=y?

python - 使用 find_peaks_cwt 在噪声数据中查找峰值

python - 使用 Python 生成模拟输入文件