genCDFInv_akima: Generate an Inverse CDF Function Using Akima Spline...

View source: R/genCDFInv_akima.R

genCDFInv_akimaR 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:

  1. Computes the empirical CDF (ECDF) of the dataset.

  2. Extracts the sorted ECDF values for the dataset.

  3. Sorts the original data values.

  4. 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

ecdf, aspline

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


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