weighted_ecdf {ggdist} | R Documentation |
Weighted empirical cumulative distribution function
Description
A variation of ecdf()
that can be applied to weighted samples.
Usage
weighted_ecdf(x, weights = NULL, na.rm = FALSE)
Arguments
x |
numeric vector: sample values |
weights |
Weights for the sample. One of:
|
na.rm |
logical: if |
Details
Generates a weighted empirical cumulative distribution function, .
Given
, a sorted vector (derived from
x
), and , the corresponding
weight
for ,
is a step function with steps at each
with
equal to the sum of all weights up to and including
.
Value
weighted_ecdf()
returns a function of class "weighted_ecdf"
, which also
inherits from the stepfun()
class. Thus, it also has plot()
and print()
methods. Like ecdf()
, weighted_ecdf()
also provides a quantile()
method,
which dispatches to weighted_quantile()
.
See Also
Examples
weighted_ecdf(1:3, weights = 1:3)
plot(weighted_ecdf(1:3, weights = 1:3))
quantile(weighted_ecdf(1:3, weights = 1:3), 0.4)