View source: R/genCDFInv_akima.R
genCDFInv_akima | R Documentation |
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.
genCDFInv_akima(X)
X |
A numeric vector. The dataset for which the inverse CDF is to be created. |
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.
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.
ecdf
, aspline
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.