baml.FloatStats

Statistical reductions for `float[]`.

Reference version

Signature

interface baml.FloatStats

Statistical reductions for float[].

Unlike Summable, which also covers int[], this interface has a single implementor: mean and median are defined only for float[]. It exists so the reductions attach as methods — xs.mean(), xs.median() — to the structural float[] type. Both reject the empty array rather than inventing a value for it.

Source:<builtin>/baml/containers.bamlbytes 35365–35927

Required instance methods

function

mean

(self) -> float throws baml.errors.InvalidArgument

The arithmetic mean (average) of self.

Throws

  • baml.errors.InvalidArgument when self is empty — the mean of no elements is undefined.
function

median

(self) -> float throws baml.errors.InvalidArgument

The median of self: the middle element once the values are ordered, or the mean of the two middle elements when the count is even.

Throws

  • baml.errors.InvalidArgument when self is empty.