ferray-stats
NumPy-equivalent statistics, reductions, sorting, searching, and histograms for the ferray scientific computing library.
Part of the ferray workspace — a Rust-native, drop-in NumPy replacement. All functions operate on ferray-core's NdArray<T, D>, return FerrayResult<T>, and never panic.
Overview
- Reductions —
sum,prod,min,max,argmin,argmax,ptp(peak-to-peak),cumsum,cumprod, plus pre-allocated_intoand reusable_withvariants. Summation uses pairwise SIMD accumulation for accuracy and speed. NaN-propagating by default. - Descriptive statistics —
mean,var,std_,average(weighted),median, withddofcontrol and axis support. scipy-parity helpers:skew,kurtosis,zscore,mode,iqr,sem,gmean,hmean. - Quantiles —
quantile,percentile, andmedian, withquantile_with_method/percentile_with_methodexposing all nine Hyndman–Fan interpolation methods plus the selection styles (Linear,Lower,Higher,Nearest,Midpoint) via theQuantileMethodenum. - NaN-aware variants —
nansum,nanprod,nanmin,nanmax,nanargmin,nanargmax,nanmean,nanvar,nanstd,nancumsum,nancumprod,nanmedian,nanquantile,nanpercentile. - Sorting —
sort,argsort,partition,argpartition,lexsort,sort_complex, andsearchsorted/searchsorted_with_sorter(withSortKindandSideenums). - Searching —
nonzero,where_/where_condition/where_broadcast,count_nonzero,unique(andunique_values,unique_counts,unique_inverse,unique_all,unique_axis), plus set ops (union1d,intersect1d,setdiff1d,setxor1d,in1d,isin). - Histograms —
histogram,histogram2d,histogramdd,histogram_bin_edges,bincount,digitize(with theBinsstrategy enum). - Correlation & hypothesis tests —
corrcoef,cov,correlate, pluspearsonr,spearmanr,ttest_1samp,ttest_ind,ks_2samp,chi2_contingency.
Large arrays dispatch to a Rayon-parallel path above an element-count threshold (parallel module).
NumPy correspondence
| NumPy | ferray-stats |
|---|---|
np.sum / np.prod / np.ptp |
sum, prod, ptp |
np.mean / np.std / np.var |
mean, std_, var |
np.median / np.average |
median, average |
np.quantile / np.percentile |
quantile, percentile (+ *_with_method) |
np.argmin / np.argmax |
argmin, argmax |
np.cumsum / np.cumprod |
cumsum, cumprod |
np.sort / np.argsort |
sort, argsort |
np.partition / np.argpartition |
partition, argpartition |
np.lexsort / np.searchsorted |
lexsort, searchsorted |
np.nonzero / np.flatnonzero |
nonzero |
np.where / np.count_nonzero |
where_, count_nonzero |
np.unique |
unique (+ unique_counts, unique_inverse, …) |
np.histogram / np.bincount / np.digitize |
histogram, bincount, digitize |
np.nan* (e.g. np.nanmean) |
nanmean, nanstd, nanquantile, … |
Feature flags
This crate defines no Cargo features. It always builds against ferray-core, ferray-ufunc, rayon, num-traits, num-complex, and pulp on the workspace MSRV with no optional runtime dependencies.
Example
use ;
use *;
let a = linspace?;
// Descriptive statistics (axis = None reduces the whole array).
let m = mean?;
let s = std_?; // ddof = 0
// Median via the 0.5 quantile (NumPy-default linear interpolation).
let med = quantile?;
// Explicit interpolation method.
let p90 = quantile_with_method?;
# Ok::
This crate is re-exported through the umbrella ferray crate.
MSRV & edition
- Edition 2024, MSRV 1.88
- License: MIT OR Apache-2.0