powered by
normalize_pdf normalizes a pdf so that the integral of the pdf is equal to 1
normalize_pdf
normalize_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 <- 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