Rand-array-iid
A rust crate to create arrays whose elements are independently identically distributed.
Install
[dependencies]
rand-array-iid = "0.1.0"
Examples
An array of normally distributed scalars
use IIDDistr;
use Distribution;
use StandardNormal;
let distr = new;
let mut rng = thread_rng;
// Each of x element is distributed according to StandardNormal.
let x : = distr.sample;
An array of 3D vectors sampled from the unit sphere
use IIDDistr;
use Distribution;
use UnitSphere;
let distr = new;
let mut rng = thread_rng;
// Each of x element is sampled uniformly from the surface of the 3D unit sphere.
let x : = distr.sample;
Why only arrays?
Collections such as Vec
that implement std::iter::FromIterator
bear
no information on their size in their type, hence the distribution would have
to be restricted to a given size. They can also be sampled as follow:
use Distribution;
use Rng;