1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
    Appellation: impl_rand <impls>
    Contrib: FL03 <jo3mccain@icloud.com>
*/
use crate::params::Parameter;
use crate::rand::GenerateRandom;
use ndarray::{Array, Dimension};
use ndrand::rand_distr::uniform::SampleUniform;
use ndrand::rand_distr::{Distribution, StandardNormal};
use num::Float;

impl<T, D> Parameter<T, D>
where
    D: Dimension,
    T: Float + SampleUniform,
    StandardNormal: Distribution<T>,
{
    pub fn init_uniform(mut self, dk: T) -> Self {
        let dim = self.value.dim();
        self.value = Array::uniform_between(dk, dim);
        self
    }
}