简体   繁体   中英

How to reuse my kernel density estimation function in R?

I use density() to do KDE ,like

 #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?

Tanks for sharing your idea!

Because density() gives you the continous KDE, the probability of an exact value is zero. You can only get some information like P(x <= 1). In your case hist() should be the correct selection.

EDIT: Please have a look here
https://stats.stackexchange.com/questions/78711/how-to-find-estimate-probability-density-function-from-density-function-in-r

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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