Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

q_approxfun

Quantile Function Approximation


Description

q_approxfun is a generic function that for a given object generates function to approximate the quantile function.

Usage

q_approxfun(O, range = q(O, c(0.005, 0.995)), n = 1000)

## S3 method for class 'dist'
q_approxfun(O, range = q(O, c(0.005, 0.995)), n = 1000)

Arguments

O

distribution object.

range

interval on which the grid is defined, q(O, c(0.005, 0.995)).

n

number of points within the grid, default: 1000.

Details

Function q_approxfun generates a grid of values on which the CDF of the object is evaluated. The function returns a quantile function that uses approx and the values of the grid to approximate the quantiles. This function is designed mostly for the mixture distributions where the standard q method may be slow and thus allows to trade the accuracy for the speed.

The returned function takes the arguments p, lower.tail and log.p, see q.

Value

Function.

Examples

N <- normdist(1, 3)
N2 <- normdist(8, 3)

M <- mixdist(N, N2, weights = c(0.5, 0.5))
q_app <- q_approxfun(M)

q_app(c(.2, .5, .7))
q_app(c(.2, .5, .7), lower.tail = FALSE)

mistr

Mixture and Composite Distributions

v0.0.4
GPL-3
Authors
Lukas Sablica [aut, cre] (<https://orcid.org/0000-0001-9166-4563>), Kurt Hornik [aut] (<https://orcid.org/0000-0003-4198-9911>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.