RtoDPQ.LC {distr}R Documentation

Default procedure to fill slots d,p,q given r for Lebesgue decomposed distributions

Description

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

Usage

RtoDPQ.LC(r, e = getdistrOption("RtoDPQ.e"), n = getdistrOption("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.LC generates 10^e random numbers, by default

e = RtoDPQ.e

. Replicates are assumed to be part of the discrete part, unique values to be part of the a.c. part of the distribution. For the replicated ones, we generate a discrete distribution by a call to DiscreteDistribution. The a.c. density is formed on the basis of n points using approxfun and density (applied to the unique values), by default

n = DefaultNrGridPoints

. The cumulative distribution function is based on all random variables, and, as well as the quantile function, is 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.LC returns an object of class UnivarLebDecDistribution.

Note

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

Author(s)

Peter Ruckdeschel Peter.Ruckdeschel@itwm.fraunhofer.de

See Also

UnivariateDistribution-class, density, approxfun, ecdf

Examples

rn2 <- function(n)ifelse(rbinom(n,1,0.3),rnorm(n)^2,rbinom(n,4,.3))
x <- RtoDPQ.LC(r = rn2, e = 4, n = 512)
plot(x)
# returns density, cumulative distribution and quantile function of
# squared standard normal distribution
d.discrete(x)(4)
x2 <- RtoDPQ.LC(r = rn2, e = 5, n = 1024) # for a better result
plot(x2)

[Package distr version 2.0.6 Index]