# RtoDPQ

From distr v1.5
0th

Percentile

##### RtoDPQ

function to do get empirical density, cumulative distribution and quantile function from random numbers

##### Usage
RtoDPQ(r, e = RtoDPQ.e, n = DefaultNrGridPoints)
##### Arguments
r
the random number generator
e
$10^e$ numbers are generated, a higher number leads to a better result.
n
The number of grid points used to create the approximated functions, a higher number leads to a better result.
##### Details

RtoDPQ generates $10^e$ random numbers, by default $$e = RtoDPQ.e$$. The density is formed on the basis of $n$ points using approxfun and density, by default $$n = DefaultNrGridPoints$$. The cumulative distribution function and the quantile function are also created on the basis of $n$ points using approxfun and ecdf. Of course, the results are usually not exact as they rely on random numbers.

##### Value

• RtoDPQ returns a list of functions.
• dfundensity
• pfuncumulative distribution function
• qfunquantile function

##### Note

Use RtoDPQ for absolutely continuous and RtoDPQ.d for discrete distributions.

##### code

ecdf

UnivariateDistribution-class

• RtoDPQ
##### Examples
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
x\$dfun(4)
RtoDPQ(r = rn2, e = 5, n = 1024) # for a better result

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
Documentation reproduced from package distr, version 1.5, License: GPL (version 2 or later)

### Community examples

Looks like there are no examples yet.