Learn R Programming

exPrior (version 1.0.1)

smooth_pdf: Smooths a pdf

Description

smooth_pdf smooths a pdf using convolution with a kernel

Usage

smooth_pdf(x, p_x)

Arguments

x

a vector corresponding to values of a random variable X (length strictly greater than 1)

p_x

a vector containing the density of the RV X at locations x

Value

The normalized pdf

Examples

Run this code
# 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