probs

Crates.ioprobs
lib.rsprobs
version0.3.1
sourcesrc
created_at2022-02-13 12:40:45.841927
updated_at2022-02-18 10:21:01.003911
descriptionStatistics toolkit
homepage
repositoryhttps://github.com/mrlazy1708/probs
max_upload_size
id531745
size21,134
Yiheng Du (mrlazy1708)

documentation

https://docs.rs/probs/latest/probs

README

probs

Provide definition of domain and basic distribution. Implement various sampler with Iterator.

Basic Usage

Construct a sampler of certain sampling technique

use sampler::Global;
fn test() {
  sampler::univar::Icdf::new()

Sample a distribution with it

    .sample(distribution::univar::normal::<i8>(0.0, 32.0))

Use it like an Iterator as you would

    .enumerate()
    .for_each(|(i, x)| println!("sample#{}: {}", i, x))
}

Arbitrary Distribution

ANY customized distribution can be sampled with provided samplers

sampler::univar::Icdf::new()
  .sample(|x: &u8| (x % 8) as f64)

Multi-dimensional

Gibbs Sampler is used to sample distribution on high dimension

  • Fix-dimensioned domain is represented with ndarray
sampler::univar::Icdf::new()
  .gibbs(nd::Dim([2, 2]), 100) // 2x2 domain; skip first 100 samples
  .sample(|m: &nd::Array2<u8>| m.sum() as f64)
Commit count: 0

cargo fmt