smooth_pdf: Smooths a pdf

Description Usage Arguments Value Examples

View source: R/utils.R

Description

smooth_pdf smooths a pdf using convolution with a kernel

Usage

1
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

1
2
3
4
5
6
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')

exPrior documentation built on Nov. 15, 2019, 1:07 a.m.