q_approxfun: Quantile Function Approximation

View source: R/standist.R

q_approxfunR Documentation

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 documentation built on March 7, 2023, 7:42 p.m.