1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use rand;
use rand::Rng;
use rand::distributions::normal::{StandardNormal};
use super::matrix::*;
use matrix::traits::*;
#[allow(deprecated)]
pub fn rand_std_normal(rows: usize, cols : usize)-> MatrixF64 {
let mut m : Matrix<f64> = Matrix::new(rows, cols);
let mut rng = rand::thread_rng();
for c in 0..cols{
for r in 0..rows{
let StandardNormal(n) = rng.gen::<StandardNormal>();
m.set(r, c, n);
}
}
m
}
#[cfg(test)]
#[allow(unused_imports)]
mod tests {
use api::*;
#[test]
fn test_rand_std_normal(){
let m1 = super::rand_std_normal(10, 10);
assert_eq!(m1.num_cells(), 100);
}
}