diff --git a/Cargo.toml b/Cargo.toml index e3fe154..177fdcd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,8 +38,9 @@ version = "0.3" [dev-dependencies] bencher = "0.1" -rand = "0.6" -rand_xoshiro = "0.1" +rand = "0.7" +rand_xoshiro = "0.3" +rand_distr = "0.2" serde_json = "1" streaming-stats = "0.2" quantiles = "0.7" diff --git a/tests/histogram.rs b/tests/histogram.rs index 0754949..e4a8790 100644 --- a/tests/histogram.rs +++ b/tests/histogram.rs @@ -2,6 +2,8 @@ extern crate core; extern crate rand; +extern crate rand_xoshiro; +extern crate rand_distr; #[cfg(feature = "serde1")] #[macro_use] extern crate serde_derive; #[cfg(feature = "serde1")] @@ -10,8 +12,8 @@ extern crate serde_json; #[macro_use] extern crate serde_big_array; use core::iter::Iterator; -use rand::distributions::Distribution; -use rand::FromEntropy; +use rand::SeedableRng; +use rand_distr::Distribution; use average::{Histogram, Merge}; @@ -197,8 +199,8 @@ fn mul() { #[test] fn variance() { let mut h = Histogram10::with_const_width(-3., 3.); - let normal = rand::distributions::Normal::new(0., 1.); - let mut rng = rand::rngs::SmallRng::from_entropy(); + let normal = rand_distr::Normal::new(0., 1.).unwrap(); + let mut rng = rand_xoshiro::Xoshiro256StarStar::from_entropy(); for _ in 0..1000000 { let _ = h.add(normal.sample(&mut rng)); } diff --git a/tests/random.rs b/tests/random.rs index bc1b0dc..02d69a6 100644 --- a/tests/random.rs +++ b/tests/random.rs @@ -3,15 +3,15 @@ #[macro_use] extern crate average; extern crate rand; +extern crate rand_distr; -use rand::distributions::Distribution; +use rand_distr::Distribution; use average::{Kurtosis, Estimate}; #[test] fn normal_distribution() { - use rand::distributions::Normal; - let normal = Normal::new(2.0, 3.0); + let normal = rand_distr::Normal::new(2.0, 3.0).unwrap(); let mut a = Kurtosis::new(); for _ in 0..1_000_000 { a.add(normal.sample(&mut ::rand::thread_rng())); @@ -26,9 +26,8 @@ fn normal_distribution() { #[test] fn exponential_distribution() { - use rand::distributions::Exp; let lambda = 2.0; - let normal = Exp::new(lambda); + let normal = rand_distr::Exp::new(lambda).unwrap(); let mut a = Kurtosis::new(); for _ in 0..6_000_000 { a.add(normal.sample(&mut ::rand::thread_rng())); diff --git a/tests/streaming_stats.rs b/tests/streaming_stats.rs index aad3e21..0d49e5d 100644 --- a/tests/streaming_stats.rs +++ b/tests/streaming_stats.rs @@ -3,17 +3,18 @@ #[macro_use] extern crate average; extern crate rand; +extern crate rand_xoshiro; +extern crate rand_distr; extern crate stats; /// Create a random vector by sampling from a normal distribution. fn initialize_vec(size: usize) -> Vec { - use rand::distributions::{Normal, Distribution}; + use rand_distr::{Normal, Distribution}; + use rand_xoshiro::Xoshiro256StarStar; use rand::SeedableRng; - use rand::rngs::SmallRng; - let normal = Normal::new(2.0, 3.0); + let normal = Normal::new(2.0, 3.0).unwrap(); let mut values = Vec::with_capacity(size); - let mut rng = SmallRng::from_seed( - [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); + let mut rng = Xoshiro256StarStar::seed_from_u64(42); for _ in 0..size { values.push(normal.sample(&mut rng)); }