Learn R Programming

exPrior (version 1.0.1)

normalize_pdf: Normalize a pdf

Description

normalize_pdf normalizes a pdf so that the integral of the pdf is equal to 1

Usage

normalize_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 <- 2*dnorm(x)
res <- normalize_pdf(x,p_x)
plot(x,p_x)
lines(x,res$p_x)
lines(x,dnorm(x),col='red',lty=2)
# }

Run the code above in your browser using DataLab