stat-ecdf
ECDF statistic: one row per unique x value with the cumulative fraction.
Numeric x values are parsed via parse-number; none and unparseable inputs are dropped. For each unique value v in the sorted sample, y is the cumulative weighted count of observations less than or equal to v divided by the total weight, matching R’s ecdf(x)(v). Output rows are sorted by x ascending.
Usage
stat-ecdf()Returns
Statistic object with name: "ecdf", consumed by geom layers.
Outputs
x.y.
Examples
ECDF curve over a tiny sample, drawn as a polyline.
#let d = (3, 1, 2, 1).map(v => (x: v))
#plot(
data: d,
mapping: aes(x: "x"),
layers: (geom-line(stat: "ecdf"),),
width: 10cm,
height: 6cm,
)Constructor form: stat: stat-ecdf() is equivalent to stat: "ecdf" with defaults. Mapping colour to a group column produces one ECDF per group; both syntax forms honour aesthetic grouping identically.
#let d = ()
#for grp in ("a", "b") {
for i in range(0, 15) {
d.push((x: i + (if grp == "b" { 3 } else { 0 }), grp: grp))
}
}
#plot(
data: d,
mapping: aes(x: "x", colour: "grp"),
layers: (geom-line(stat: stat-ecdf(), stroke: 1pt),),
width: 10cm,
height: 6cm,
)