smooth_quantile_distribution: Fit a Smooth Empirical Distribution from Quantiles

View source: R/smooth-quantile-distribution.R

smooth_quantile_distributionR Documentation

Fit a Smooth Empirical Distribution from Quantiles

Description

Fits a smooth empirical quantile function and derives an interpolated density, cumulative distribution, quantile function, and random sampler.

Usage

smooth_quantile_distribution(
  x,
  probs = seq(0.001, 0.999, length.out = 1000),
  spar = NULL,
  density_spar = NULL,
  eps = 1e-06,
  enforce_monotone = TRUE,
  plot_result = FALSE
)

Arguments

x

Numeric vector of observations. Non-finite values are removed.

probs

Probability grid strictly inside (0, 1).

spar

Optional smoothing parameter passed to stats::smooth.spline() for the quantile function.

density_spar

Optional smoothing parameter passed to stats::smooth.spline() for the implied density.

eps

Small positive lower bound used in derivative and probability calculations.

enforce_monotone

Logical. If TRUE, enforce monotonicity of the smoothed quantile curve.

plot_result

Logical. If TRUE, plot the fitted quantile curve and implied density.

Value

A list with data, dfun, pfun, qfun, rfun, q_fit, d_fit, and original_x.

Examples

set.seed(1)
fit <- smooth_quantile_distribution(rnorm(100), probs = seq(0.05, 0.95, length.out = 50))
fit$qfun(c(0.25, 0.5, 0.75))
fit$dfun(0)

CRAFT documentation built on Nov. 2, 2026, 9:06 a.m.