项目作者: stainless-steel

项目描述 :
Probability-theory toolbox
高级语言: Rust
项目地址: git://github.com/stainless-steel/probability.git
创建时间: 2014-10-18T14:04:40Z
项目社区:https://github.com/stainless-steel/probability

开源协议:Other

下载


Probability Package Documentation Build

The package provides a probability-theory toolbox.

Example

  1. use probability::prelude::*;
  2. let mut source = source::default(42);
  3. let distribution = Uniform::new(0.0, 1.0);
  4. let sampler = Independent(&distribution, &mut source);
  5. let samples = sampler.take(10).collect::<Vec<_>>();

Sources of randomness are provided by the random crate via the
source module. In addition, one can make use of those sources that are
available in the rand crate as illustrated below:

  1. use probability::prelude::*;
  2. struct Source<T>(T);
  3. impl<T: rand::RngCore> source::Source for Source<T> {
  4. fn read_u64(&mut self) -> u64 {
  5. self.0.next_u64()
  6. }
  7. }
  8. let mut source = Source(rand::rngs::OsRng::new().unwrap());
  9. let distribution = Uniform::new(0.0, 1.0);
  10. let sampler = Independent(&distribution, &mut source);
  11. let samples = sampler.take(10).collect::<Vec<_>>();

Contribution

Your contribution is highly appreciated. Do not hesitate to open an issue or a
pull request. Note that any contribution submitted for inclusion in the project
will be licensed according to the terms given in LICENSE.md.