genCDFInv_akima {covalchemy} | R Documentation |
Generate an Inverse CDF Function Using Akima Spline Interpolation
Description
This function creates an inverse cumulative distribution function (CDF)
for a given dataset using Akima spline interpolation. The resulting function
maps probabilities (in the range [0, 1]
) to values in the dataset.
Usage
genCDFInv_akima(X)
Arguments
X |
A numeric vector. The dataset for which the inverse CDF is to be created. |
Details
The function works as follows:
Computes the empirical CDF (ECDF) of the dataset.
Extracts the sorted ECDF values for the dataset.
Sorts the original data values.
Uses the
aspline
function to create a spline interpolation mapping probabilities to dataset values.
The resulting function leverages Akima splines, which are smooth and flexible for interpolating data.
Value
A function that takes a single argument, p
, a numeric vector of
probabilities in [0, 1]
, and returns the corresponding values interpolated
from the dataset using Akima splines.
See Also
Examples
# Example usage:
library(interp)
data <- c(1, 2, 3, 4, 5)
inv_cdf <- genCDFInv_akima(data)
inv_cdf(c(0.1, 0.5, 0.9)) # Compute interpolated values for given probabilities