Update dependencies

This commit is contained in:
Vinzent Steinberg 2018-07-06 10:31:26 +02:00
parent 9f1c28147c
commit 7f8663c23e
4 changed files with 18 additions and 14 deletions

View File

@ -23,7 +23,7 @@ harness = false
name = "kurtosis"
[dependencies]
num-traits = "0.1"
num-traits = "0.2"
num-integer = "0.1"
quickersort = "3"
@ -38,6 +38,6 @@ version = "1"
[dev-dependencies]
bencher = "0.1"
rand = "0.3"
rand = "0.5"
serde_json = "1"
streaming-stats = "0.1"
streaming-stats = "0.2"

View File

@ -4,7 +4,8 @@ extern crate core;
extern crate rand;
use core::iter::Iterator;
use rand::distributions::IndependentSample;
use rand::distributions::Distribution;
use rand::FromEntropy;
use average::Histogram;
@ -188,9 +189,9 @@ fn mul() {
fn variance() {
let mut h = Histogram10::with_const_width(-3., 3.);
let normal = rand::distributions::Normal::new(0., 1.);
let mut rng = rand::weak_rng();
let mut rng = rand::rngs::SmallRng::from_entropy();
for _ in 0..1000000 {
let _ = h.add(normal.ind_sample(&mut rng));
let _ = h.add(normal.sample(&mut rng));
}
println!("{:?}", h);
let sum: u64 = h.bins().iter().sum();

View File

@ -4,15 +4,17 @@
extern crate rand;
use rand::distributions::Distribution;
use average::{Kurtosis, Estimate};
#[test]
fn normal_distribution() {
use rand::distributions::{Normal, IndependentSample};
use rand::distributions::Normal;
let normal = Normal::new(2.0, 3.0);
let mut a = Kurtosis::new();
for _ in 0..1_000_000 {
a.add(normal.ind_sample(&mut ::rand::thread_rng()));
a.add(normal.sample(&mut ::rand::thread_rng()));
}
assert_almost_eq!(a.mean(), 2.0, 1e-2);
assert_almost_eq!(a.sample_variance().sqrt(), 3.0, 1e-2);
@ -24,12 +26,12 @@ fn normal_distribution() {
#[test]
fn exponential_distribution() {
use rand::distributions::{Exp, IndependentSample};
use rand::distributions::Exp;
let lambda = 2.0;
let normal = Exp::new(lambda);
let mut a = Kurtosis::new();
for _ in 0..6_000_000 {
a.add(normal.ind_sample(&mut ::rand::thread_rng()));
a.add(normal.sample(&mut ::rand::thread_rng()));
}
assert_almost_eq!(a.mean(), 1./lambda, 1e-2);
assert_almost_eq!(a.sample_variance().sqrt(), 1./lambda, 1e-2);

View File

@ -7,13 +7,14 @@ extern crate stats;
/// Create a random vector by sampling from a normal distribution.
fn initialize_vec(size: usize) -> Vec<f64> {
use rand::distributions::{Normal, IndependentSample};
use rand::distributions::{Normal, Distribution};
use rand::{XorShiftRng, SeedableRng};
let normal = Normal::new(2.0, 3.0);
let mut values = Vec::with_capacity(size);
let mut rng = XorShiftRng::from_seed([1, 2, 3, 4]);
let mut rng = XorShiftRng::from_seed(
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
for _ in 0..size {
values.push(normal.ind_sample(&mut rng));
values.push(normal.sample(&mut rng));
}
values
}
@ -33,5 +34,5 @@ fn average_vs_streaming_stats_large() {
let a: average::MeanWithError = values.iter().collect();
let b: stats::OnlineStats = values.iter().map(|x| *x).collect();
assert_almost_eq!(a.mean(), b.mean(), 1e-16);
assert_almost_eq!(a.population_variance(), b.variance(), 1e-13);
assert_almost_eq!(a.population_variance(), b.variance(), 1e-12);
}