# NOT RUN {
### Use existing bandwidth selection with the package
### generate sample from bimodal Gaussian mixture with varying scale
x <- c(rnorm(100000), rnorm(100000)/4 + 2)
### estimate bandwidth using bw.SJ
bwsj <- h_Gauss_to_K(bw.SJ(x), c(.25,.25))
xs <- seq(-3, 4, length = 1000)
plot(xs, dnorm(xs)/2+dnorm(xs,2,1/4)/2, type = 'l',
col = rgb(.7, .7, .7), lwd = 4)
lines(fk_density(x, h = bwsj), lty = 2, lwd = 2)
# }
Run the code above in your browser using DataLab