genCDFInv_quantile: Generate an Inverse CDF Function Using Quantiles

View source: R/genCDFInv_quantile.R

genCDFInv_quantileR 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 quantile for details. Default is 1.

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

quantile

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


covalchemy documentation built on April 12, 2025, 2:15 a.m.