statistics

Statistical Functions (Integer-Scaled)

Functions

FunctionDescription
stat_sumSum of all values.
stat_mean_x10kMean * 10000.
_stat_sortInternal: simple insertion sort for small arrays.
stat_medianMedian (middle value of sorted data).
stat_modeMode (most frequent value). Uses O(n^2) counting to avoid alloc_pages overlap.
stat_minMinimum value.
stat_maxMaximum value.
stat_rangeRange (max - min).
stat_variance_x10kVariance * 10000. Uses sum of squared deviations.
_stat_isqrtInteger square root (helper for stdev).
stat_stdev_x10kStandard deviation * 10000.
stat_percentilePercentile (0-100). Returns value at that percentile.

Details

stat_sum

fn stat_sum(data: &i64, n: i64) -> i64

Sum of all values.

stat_mean_x10k

fn stat_mean_x10k(data: &i64, n: i64) -> i64

Mean * 10000.

_stat_sort

fn _stat_sort(data: &i64, n: i64, out: &i64)

Internal: simple insertion sort for small arrays.

stat_median

fn stat_median(data: &i64, n: i64) -> i64

Median (middle value of sorted data).

stat_mode

fn stat_mode(data: &i64, n: i64) -> i64

Mode (most frequent value). Uses O(n^2) counting to avoid alloc_pages overlap.

stat_min

fn stat_min(data: &i64, n: i64) -> i64

Minimum value.

stat_max

fn stat_max(data: &i64, n: i64) -> i64

Maximum value.

stat_range

fn stat_range(data: &i64, n: i64) -> i64

Range (max - min).

stat_variance_x10k

fn stat_variance_x10k(data: &i64, n: i64) -> i64

Variance * 10000. Uses sum of squared deviations.

_stat_isqrt

fn _stat_isqrt(n: i64) -> i64

Integer square root (helper for stdev).

stat_stdev_x10k

fn stat_stdev_x10k(data: &i64, n: i64) -> i64

Standard deviation * 10000.

stat_percentile

fn stat_percentile(data: &i64, n: i64, p: i64) -> i64

Percentile (0-100). Returns value at that percentile.