View source: R/weighted_ecdf.R
weighted_ecdf | R Documentation |
A variation of ecdf()
that can be applied to weighted samples.
weighted_ecdf(x, weights = NULL, na.rm = FALSE)
x |
numeric vector: sample values |
weights |
Weights for the sample. One of:
|
na.rm |
logical: if |
Generates a weighted empirical cumulative distribution function, F(x)
.
Given x
, a sorted vector (derived from x
), and w_i
, the corresponding
weight
for x_i
, F(x)
is a step function with steps at each x_i
with F(x_i)
equal to the sum of all weights up to and including w_i
.
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()
.
weighted_quantile()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.