1 个不稳定版本

0.1.0 2021 年 11 月 28 日

#1845 in 数学

MIT 许可证

11KB
211

samplr

samplr 是一个 CLI 工具,用于随机抽样数据;以均匀概率生成固定大小的输入行样本。

安装

源代码

需要已安装 Rust

git clone https://github.com/SteadBytes/sample.git
cd sample
cargo install --path .

示例

从文件中抽取 15 行样本

sample -n 15 things.txt

从标准输入中抽取 15 行样本

<things.txt | sample -n 15

从多个文件中抽取 15 行样本

sample -n 15 things.txt other_things.txt

抽样算法

samplr 使用 Reservoir Sampling 算法从未知长度的输入流中生成固定大小的样本。更多详细信息,请参阅 实现 和链接的 博客文章

开发

测试

运行单元测试

cargo test

运行所有测试(包括可能计算密集型的统计测试)

cargo test --all-features --release

依赖项

~1MB
~12K SLoC