stats
cheatah-plot v0.1.0-alpha — Biome Standard 0.6.3-alpha
Classes
Hist— A binned histogram: everything a bar mark needs to draw it.
Functions
Uniform-bin histogram of data over its widened range (plot.scale.data_range, so flat or empty data still bins sanely).
NaN values are skipped; values at or beyond the top edge land in the last bin (the conventional right-inclusive tail).
data | the samples. |
bins | the bin count (clamped up to at least 1). |
the Hist with edges, centers, and counts.
O(n + bins).
the three returned arrays.
systests/test_stats.purrimport plot.stats as stats
import ndarray
let data = ndarray.array([0.0, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0])
let h = stats.histogram(data, 4) # -> h.centers/h.counts are bar-ready arraysinline ::cheatah::ndarray::basic_ndarray< double > fit(::cheatah::ndarray::basic_ndarray< double > &x, ::cheatah::ndarray::basic_ndarray< double > &y)
#
The least-squares LINE through (x, y), evaluated at each x — pass it straight to a line mark to overlay the trend (figure.line(x, stats.fit(x, y))).
The solve is linalg.lstsq on the [x, 1] design matrix; this function only assembles operands and evaluates the result.
x | the x positions. |
y | the y values (same length). |
the fitted line's y at each x (fewer than 2 points: y unchanged — no line to fit).
O(n) assembly + the lstsq solve.
the design/rhs operands and the returned array.
systests/test_stats.purrimport plot.figure as figure
import plot.stats as stats
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0, 3.0])
let y = ndarray.array([1.1, 2.9, 5.2, 6.8])
let trend = stats.fit(x, y)
let f = figure.new_figure()
f = figure.line(f, x, trend) # -> the least-squares trend over the dataThe standard error of the mean — the honest default magnitude for symmetric error bars (statistics.stdev under the hood; this function only supplies the √n).
data | the samples. |
stdev(data) / √n (0 when fewer than 2 samples — no spread to estimate).
O(n).
one transient list copy (statistics consumes lists).
systests/test_stats.purrimport plot.stats as stats
import ndarray
let data = ndarray.array([1.0, 2.0, 3.0, 4.0])
let e = stats.sem(data) # -> 0.645...: stdev / sqrt(4), an errorbar magnitudeABI/identity marker for the stats cheatah module: returns the module name.
Auto-emitted by purrc's library emitter. It is the concrete symbol that anchors the module's signed static archive in opaque (source-hidden) builds.
the module name ("stats").
