Description Usage Arguments Value Author(s) Examples
View source: R/pdf_from_quantiles_function.R
Reconstruct a PDF based on a set of quantiles of a distribution or the quantile function (inverse cumulative distribution function ICDF)
1 | pdf_from_quantiles(q.vec, p.vec, x.vec)
|
q.vec |
Vector of quantiles (quantile function / inverse CDF; has to be sorted in increasing order) |
p.vec |
Vector of probabilities (values between 0 and 1 providing the probability associated with each element of q.vec) |
x.vec |
Vector of values for which the densities should be returned |
Vector of probability densities for each element in x.vec
Nikolai Knapp, nikolai.knapp@ufz.de
1 2 3 4 5 6 7 8 9 10 11 | my.r.vec <- rnorm(n=50, mean=10, sd=6)
my.q.vec <- sort(my.r.vec)
my.p.vec <- pnorm(my.q.vec, mean=10, sd=6)
plot(my.q.vec ~ my.p.vec, type="l")
my.x.vec <- -20:40
my.pdf.vec <- pdf_from_quantiles(q.vec=my.q.vec, p.vec=my.p.vec,
x.vec=my.x.vec)
hist(my.r.vec, freq=F, xlim=c(-20, 40))
lines(my.pdf.vec ~ my.x.vec, col="red")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.