How to calculate cumulative distribution in R?
ecdffunction applied to a data sample returns a function representing the empirical cumulative distribution function. For example:
> X = rnorm(100) # X is a sample of 100 normally distributed random variables > P = ecdf(X) # P is a function giving the empirical CDF of X > P(0.0) # This returns the empirical CDF at zero (should be close to 0.5)  0.52 > plot(P) # Draws a plot of the empirical CDF (see below)
If you want to have an object representing the empirical CDF evaluated at specific values (rather than as a function object) then you can do
> z = seq(-3, 3, by=0.01) # The values at which we want to evaluate the empirical CDF > p = P(z) # p now stores the empirical CDF evaluated at the values in z
pcontains at most the same amount of information as
P(and possibly it contains less) which in turn contains the same amount of information as
Yes i know, but how is it possible to access the values of ecdf? this is a mystery for me.
If you want its value at `x` you simply write `P(x)`. Note that `x` can be a vector (see the last couple of sentences of my answer.)