简体   繁体   English

如何在R中重用我的内核密度估计函数?

[英]How to reuse my kernel density estimation function in R?

I use density() to do KDE ,like 我用density()KDE ,就像

 #Rscript#
x <- c(rep(1,3),rep(2,4),rep(3,5))
density(x)

Am I suppose to get a probability density function? 我想得到一个概率密度函数吗? If so, How do I reuse it to obtain the probability of 1 value eg what is the probability of x<=2 P(x<=2) under my KDE function? 如果是这样,我该如何重用它以获得1值的概率,例如,在我的KDE函数下x <= 2 P(x <= 2)的概率是多少?

Tanks for sharing your idea! 分享您的想法的坦克!

Because density() gives you the continous KDE, the probability of an exact value is zero. 由于density()为您提供连续的KDE,因此精确值的可能性为零。 You can only get some information like P(x <= 1). 您只能得到一些信息,例如P(x <= 1)。 In your case hist() should be the correct selection. 在您的情况下,hist()应该是正确的选择。

EDIT: Please have a look here 编辑:请在这里看看
https://stats.stackexchange.com/questions/78711/how-to-find-estimate-probability-density-function-from-density-function-in-r https://stats.stackexchange.com/questions/78711/how-to-find-estimate-probability-density-function-from-density-function-in-r

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM