FLUTTER ECOSYSTEM

kevmoo/stats

计算一组数字的常见统计值

统计 项目封面
Stars
13
Forks
4
最近推送(UTC)
2026年9月12日
项目状态
未归档
Kevin Moore GitHub avatar
GITHUB User

Kevin Moore ↗

A Product Manager at @google working on @dart-lang and @flutter web technologies

@dart-lang @flutter @googleSeattle, WA, USA官方网站 ↗
语言Dart

技术话题

此仓库发布的插件

使用的依赖

依赖清单 7 项

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

CI Pub Package package publisher

Supports:

  • Stats: Typical statistical values over a List or Stream of num: count, min, max, mean, sumOfSquares
  • ConfidenceInterval over Stats with a given confidence level.
import 'dart:convert';

import 'package:stats/stats.dart';

void main() {
  final input = [1, 2, 3, 4, 5, 6, 7, 8];
  print('Input: $input');
  final stats = Stats.fromData(input);
  final confidence = ConfidenceInterval.calculate(
    stats,
    ConfidenceLevel.percent95,
  );

  print(_toJson(confidence));
  // {
  //   "stats": {
  //     "count": 8,
  //     "min": 1,
  //     "max": 8,
  //     "mean": 4.5,
  //     "sumOfSquares": 42.0
  //   },
  //   "marginOfError": 2.0481500799501973,
  //   "tScore": 2.365,
  //   "confidenceLevel": "percent95"
  // }
}

String _toJson(Object? value) =>
    const JsonEncoder.withIndent('  ').convert(value);