estimate_cdf {DMTL}R Documentation

Estimate Cumulative Distribution

Description

This function estimates the values of the cumulative distribution function (CDF) for a vector.

Usage

estimate_cdf(
  x,
  bootstrap = TRUE,
  samples = 1e+06,
  density = FALSE,
  binned = TRUE,
  grids = 10000,
  unit_range = FALSE,
  seed = NULL,
  ...
)

Arguments

x

Vector containing data.

bootstrap

Flag for performing bootstrapping on x to get a better estimate of the CDF. Defaults to TRUE.

samples

Sample size for bootstrapping. Defaults to 1e6. Ignored when bootstrap = FALSE.

density

Flag for calculating kernel density estimates (KDE) instead of histogram counts. Depends on the ks package for density estimation. Defaults to FALSE.

binned

Flag for calculating binned KDE. Defaults to TRUE. Ignored when density = FALSE.

grids

Size parameter for the estimation grid when density = TRUE. Used to calculate the grid sizes for KDE bandwidth estimation (grids*10), and grid size KDE estimation (bgridsize = grids if binned = TRUE else gridsize = grids/10). Defaults to 1e4.

unit_range

Flag for unity data range (i.e., data is normalized between 0 and 1). Defaults to FALSE.

seed

Seed for random number generator (for reproducible outcomes). Defaults to NULL.

...

Other options relevant for distribution estimation.

Value

If density = FALSE, a function of class ecdf, inheriting from the stepfun class, and hence inheriting a knots() method.

If density = TRUE, an object of class kcde which has the fields eval.points and estimate necessary for calculating a map.

Examples

x <- runif(100)
x_hist_cdf <- estimate_cdf(x, samples = 1000, unit_range = TRUE)
x_kde_cdf <- estimate_cdf(x, density = TRUE, unit_range = TRUE)


[Package DMTL version 0.1.2 Index]