Function to calculate the inverse function of a cumulative distribution function.
Usage
inverse(f, lower = -Inf, upper = Inf)
Arguments
f
a cdf function for which we want to obtain its inverse.
lower
the lower limit of f domain (support of the random variable), default -Inf.
upper
the upper limit of f domain (support of the random variable), default Inf.
Details
inverse is called by random.function and calculates the inverse of a given
function f. inverse has been specifically designed to compute the inverse
of the cumulative distribution function of an absolutely continuous random variable, therefore
it assumes there is only a root for each value in the interval (0,1) between f(lower)
and f(upper). It is for internal use in dgeometric.test.
Value
A function, the inverse function of a cumulative distribution function f.
Note
This function uses either optim with default options method="L-BFGS-B" or uniroot
to derive the inverse function.
The upper endpoint must be strictly larger than the lower endpoint.
Author(s)
Jose M. Pavia
References
See the references in optim and uniroot.
See Also
dgeometric.test, integrate, optim, random.function,
support.facto and uniroot.
Examples
f <- function(x) pbeta(x, shape1=2, shape2=3)
f.inv <- inverse(f,lower=0,upper=1)
f.inv(.2)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(GoFKernel)
Loading required package: KernSmooth
KernSmooth 2.23 loaded
Copyright M. P. Wand 1997-2009
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GoFKernel/inverse.Rd_%03d_medium.png", width=480, height=480)
> ### Name: inverse
> ### Title: Inverse CDF Function
> ### Aliases: inverse
> ### Keywords: ~kwd1 ~kwd2
>
> ### ** Examples
>
> f <- function(x) pbeta(x, shape1=2, shape2=3)
> f.inv <- inverse(f,lower=0,upper=1)
> f.inv(.2)
[1] 0.2123161
>
>
>
>
>
> dev.off()
null device
1
>