powered by
smooth_pdf smooths a pdf using convolution with a kernel
smooth_pdf
smooth_pdf(x, p_x)
a vector corresponding to values of a random variable X (length strictly greater than 1)
a vector containing the density of the RV X at locations x
x
The normalized pdf
# NOT RUN { x <- seq(from=-5,to=5,by=0.1) p_x <- dnorm(x) + rnorm(length(x),mean=0,sd=0.02) p_x <- pmax(p_x,0) plot(x,p_x,type='l') res <- smooth_pdf(x,p_x) lines(x,res$p_x,col='red') # }
Run the code above in your browser using DataLab