genCDFInv_quantile {covalchemy} | R Documentation |
Generate an Inverse CDF Function Using Quantiles
Description
This function creates an inverse cumulative distribution function (CDF)
for a given dataset using quantiles. The resulting function maps probabilities
(in the range [0, 1]
) to quantiles of the data.
Usage
genCDFInv_quantile(data, type = 1)
Arguments
data |
A numeric vector. The dataset for which the inverse CDF is to be created. |
type |
Integer. Specifies the algorithm used to compute quantiles.
See |
Details
The function works by wrapping the quantile
function. The
type
parameter controls the quantile computation method. For example:
Type 1 corresponds to inverse of the empirical distribution function (default).
Other types correspond to different quantile algorithms as documented in
quantile
.
Value
A function that takes a single argument, p
, a numeric vector of
probabilities in [0, 1]
, and returns the corresponding quantiles from
the data.
See Also
Examples
# Example usage:
data <- c(1, 2, 3, 4, 5)
inv_cdf <- genCDFInv_quantile(data, type = 1)
inv_cdf(c(0.25, 0.5, 0.75)) # Compute the 25th, 50th, and 75th percentiles