Reputation: 1505
library(ks)
x<-rnorm(1000)
hist(x, col="red")
y <- rkde(kde(x), n=1000)
hist(y, col="green")
y <- rkde(density(x), n=1000)
hist(y, col="blue")
The last histogram is way wrong. I've used density
before and I've found that it was accurate for far more complicated distributions. Why in this case it performs so badly? Thanks
Upvotes: 0
Views: 261
Reputation: 62003
Because you're using the function wrong. rkde
expects an object of the class kde. density
doesn't return a kde object and is structured differently.
It would be like telling somebody to shoot their pistol and handing them shotgun shells and then wondering why when they fired it didn't really do anything.
Upvotes: 3