mean-se

Mean and standard-error band: mean ± multiplier * se.

se = sd / sqrt(n) using the sample standard deviation. Returns (y: <mean>, ymin: <mean - multiplier * se>, ymax: <mean + multiplier * se>).

Usage

mean-se(
  values,
  multiplier: 1,
  weights: none,
)

Parameters

Parameter Default Description
values Array of numbers; non-numeric entries are dropped.
multiplier 1 Multiplier on the standard error.
weights none Optional array of non-negative weights (none for unit weights). Frequency-weight semantics; total weight stands in for n in the standard-error denominator.

Returns

Dict (y, ymin, ymax); all-none if values has no numerics.

Examples

One-σ band around the sample mean.

#let s = mean-se((2, 3, 4, 5, 6))
// s.y == 4, s.ymin ≈ 3.29, s.ymax ≈ 4.71

Bump multiplier to 2 for an approximate 95% interval (assuming a roughly normal sampling distribution).

#let s = mean-se((2, 3, 4, 5, 6), multiplier: 2)
Back to top