# RtoDPQ: Default procedure to fill slots d,p,q given r for a.c....

### Description

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

### Usage

 ```1 2``` ```RtoDPQ(r, e = getdistrOption("RtoDPQ.e"), n = getdistrOption("DefaultNrGridPoints"), y = NULL) ```

### 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. `y` a (numeric) vector or `NULL`

### Details

RtoDPQ generates 10^e random numbers, by default

e = RtoDPQ.e

. Instead of using simulated grid points, we have an optional parameter `y` for using N. Horbenko's quantile trick: i.e.; on an equally spaced grid `x.grid` on [0,1], apply `f(q(x)(x.grid))` and write the result to `y` and produce density and cdf from this value `y` given to `RtoDPQ` as argument (instead of simulating grid points).

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.

 `dfun ` density `pfun ` cumulative distribution function `qfun ` quantile function

### Note

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

### Author(s)

Thomas Stabla statho3@web.de,
Florian Camphausen fcampi@gmx.de,
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de,
Matthias Kohl Matthias.Kohl@stamats.de

`UnivariateDistribution-class`, `density`, `approxfun`, `ecdf`

### Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```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 ```

Search within the distr package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.