普贤教程 › 包参考
stats 包
描述统计
| 项 | 值 |
|---|---|
| 包名 | stats |
| 版本 | 0.2.0 |
| 可用版本 | 0.1.0 / 0.2.0 |
| 入口 | stats.px |
| 分类 | 数学与统计 |
| 文件数 / 行数 | 1 / 255 |
安装与引入
bash
pxpkg init # 首次 pxpkg add stats@0.2.0 pxpkg install
px
import stats所属分类教程:数学与统计
公开接口
| 函数 | 参数 |
|---|---|
stats_min | nums |
stats_var | nums, sample = true |
其余 19 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
stats_count | nums |
stats_sum | nums |
stats_max | nums |
stats_mean | nums |
stats_median | nums |
stats_stddev | nums, sample = true |
stats_mode | nums |
stats_range | nums |
stats_percentile | nums, p |
stats_quartiles | nums |
stats_iqr | nums |
stats_geomean | nums |
stats_harmmean | nums |
stats_weighted_mean | nums, weights |
stats_mad | nums |
stats_cv | nums |
stats_covariance | a, b, sample = true |
stats_correlation | a, b |
stats_summary | nums |
包内说明(源码头注释)
text
============================================================ 普贤生态库:registry/stats —— 描述统计 ------------------------------------------------------------ 纯函数库(无 IO、无状态),编译(px build)与解释(px run)双模式一致。 stats_min/max/sum/count/mean/median/var/stddev 说明: - nums 为 list[number];空列表:min/max/mean/median/var → Err - var 默认样本方差(n-1 分母);stats_var(nums, false) → 总体方差(n) - median 偶数长度取中间两数平均 ============================================================