Last chance! 50% off unlimited learning
Sale ends in
function to do get empirical density, cumulative distribution and quantile function from random numbers
RtoDPQ.d(r, e = getdistrOption("RtoDPQ.e"))
RtoDPQ returns a list of functions.
density
cumulative distribution function
quantile function
the random number generator
Thomas Stabla statho3@web.de,
Florian Camphausen fcampi@gmx.de,
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de,
Matthias Kohl Matthias.Kohl@stamats.de
RtoDPQ.d
generates RtoDPQ.e
which are used to produce a density, cdf and
quantile function.
Of course, the results are usually not exact as they rely on random numbers.
set.seed(20230508)
rn2 <- function(n){rnorm(n)^2}
x <- RtoDPQ(r = rn2, e = 4, n = 512)
# returns density, cumulative distribution and quantile function of
# squared standard normal distribution
## IGNORE_RDIFF_BEGIN
x$dfun(4)
RtoDPQ(r = rn2, e = 5, n = 1024) # for a better result
## IGNORE_RDIFF_END
rp2 <- function(n){rpois(n, lambda = 1)^2}
x <- RtoDPQ.d(r = rp2, e = 5)
# returns density, cumulative distribution and quantile function of
# squared Poisson distribution with parameter lambda=1
Run the code above in your browser using DataLab