tensor_rs/tensor_trait/
rand.rs

1use rand::prelude::StdRng;
2
3pub trait Random {
4    type TensorType;
5    type ElementType;
6
7    /// Generate a random int close on left, open on right.
8    fn rand_usize(rng: &mut StdRng,
9                dim: &[usize],
10                left: usize, right: usize) -> Self::TensorType;
11    fn bernoulli() -> Self::TensorType;
12    fn cauchy() -> Self::TensorType;
13    fn exponential() -> Self::TensorType;
14    fn geometric() -> Self::TensorType;
15    fn log_normal() -> Self::TensorType;
16    fn normal(rng: &mut StdRng,
17              dim: &[usize],
18              mean: Self::ElementType,
19              std: Self::ElementType) -> Self::TensorType;
20    fn uniform(rng: &mut StdRng,
21               dim: &[usize],
22               from: Self::ElementType,
23               to: Self::ElementType) -> Self::TensorType;
24}