pdf_from_quantiles: Reconstruct probability density function from quantiles

Description Usage Arguments Value Author(s) Examples

View source: R/pdf_from_quantiles_function.R

Description

Reconstruct a PDF based on a set of quantiles of a distribution or the quantile function (inverse cumulative distribution function ICDF)

Usage

1
pdf_from_quantiles(q.vec, p.vec, x.vec)

Arguments

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

Value

Vector of probability densities for each element in x.vec

Author(s)

Nikolai Knapp, nikolai.knapp@ufz.de

Examples

 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")

niknap/ScalingFunctions documentation built on May 22, 2021, 6:43 a.m.