Calculates the mean of a (weighted or unweighted) empirical cumulative distribution function.
# S3 method for ecdf
mean(x, trim=0, …)# S3 method for ewcdf
mean(x, trim=0, …)
The fraction (0 to 0.5) of data values to be trimmed from each end of their range, before the mean is computed.
Ignored.
A single number.
These functions are methods for the generic
mean
for the classes "ecdf"
and "ewcdf"
.
They calculate the mean of the probability distribution
corresponding to the cumulative distribution function x
.
This is equivalent to calculating the (weighted or unweighted)
mean of the original data values.
For weighted empirical cumulative distribution functions
(class "ewcdf"
) the weights will first be normalised so that they
sum to 1. The result of mean.ewcdf
is always an average or weighted average or the original data values.
The argument trim
is interpreted as a probability
under this normalised distribution; the corresponding
quantiles are computed, and data outside these quantiles is deleted
before calculating the weighted mean.
Generic mean
and
weighted.mean
.
ecdf
, ewcdf
to create the cumulative distribution functions.
stieltjes
for integration with respect to
a cumulative distribution function.
# NOT RUN {
x <- 1:5
mean(x)
mean(ecdf(x))
w <- 1:5
mean(ewcdf(x, w))
# }
Run the code above in your browser using DataLab