### 7 releases

0.3.1 | Feb 18, 2022 |
---|---|

0.3.0 | Feb 18, 2022 |

0.2.1 | Feb 16, 2022 |

0.1.2 | Feb 14, 2022 |

#**4** in #statistic

**MIT/Apache**

22KB

524 lines

# probs

Provide definition of

and basic `domain`

. Implement various `distribution`

with `sampler`

.`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

as you would`Iterator`

` ``.``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``)`

#### Dependencies

~6.5MB

~113K SLoC