ecdf
Empirical Cumulative Distribution Function

Description

Create and use an empirical cumulative distribution function for a given sample.

Usage

ecdf(x)
## S3 method for class 'ecdf':
print(x, digits = getOption("digits") - 2, ...)
## S3 method for class 'ecdf':
summary(object, ...)
## S3 method for class 'ecdf':
quantile(x, ...) 

Arguments

x, object a numeric vector of variable data for ecdf function (which will drop any NA values in it), or an ecdf object for the summary and quantile methods.
digits the number of significant digits that should be printed.
... The quantile method passes on all other arguments to the default quantile method. The summary and print methods ignore all the other arguments.

Details

The empirical cumulative distribution function(or ecdf), is the cumulative distribution function associated with the empirical measure of the sample. It is a step function that jumps up by 1/n at each of the n data points.
Lets x = (x1, ..., xn) be real random variables with the common cumulative distribution function F(t). Then the empirical cumulative distribution function is defined as:
Fn(t) = {xi<=t}/n = (1/n)*sum(indicator{xi<=t}), where i = 1, 2, ..., n.
See references http://en.wikipedia.org/wiki/Empirical_distribution_function for more details about its definition.
print.ecdf is an invisible method of print for the object of class "ecdf". It prints out the "call" attribute and and the first few and list of the knots.
summary.ecdf is an invisible method of summary for the object of class "ecdf". It returns the summary of the knots of the "ecdf" object, ignoring their counts.
quantile.ecdf is an invisible method of quantile for the object of class "ecdf". The quantiles it computes match those of the original data.
Value
ecdf(x) returns a function that may be called to evaluate the empirical distribution function of x at any desired values. The returned function has class c("ecdf", "stepfun", "function") and with attribute "call"(matched call). There are also some objects in the environment of this function: "f", "method", "n", "nobs", "x", "y", "yleft" and "yright". All of them are returned by function approxfun internally, except for "nobs", which is the number of original data by skipping NAs.
print.ecdf returns the input "ecdf" object itself invisibly.
summary.ecdf returns the summary of knots of the input "ecdf" object with attribute "header" and class name "summary.ecdf".
quantile.ecdf returns a vector of the quantiles of the original data.
plot.ecdf returns NULL, invisibly. It does nothing except warn the user that it is not implemented.
References
Shorack, G.R. and Wellner, J.A. 1986. Empirical processes with applications to statistics. New York, NY: John Wiley & Sons.
van der Vaart, A.W. 1998. Asymptotic Statistics. Cambridge, UK: Cambridge University Press.
http://en.wikipedia.org/wiki/Empirical_distribution_function.
See Also
approxfun, stepfun, quantile.
Examples
e <- ecdf(Sdatasets::fuel.frame$Mileage)
e(c(20, 30, 40))  # proportion of Mileage values at or below 20, 30, and 40
quantile(e)
quantile(Sdatasets::fuel.frame$Mileage)  # same as previous
summary(e)  # shows quantiles of unique values of Mileage
Package stats version 6.1.4-13
Package Index