11//! # Dataset Generators
22//!
3- use rand:: distributions :: Uniform ;
3+ use rand:: distr :: Uniform ;
44use rand:: prelude:: * ;
55use rand_distr:: Normal ;
66
@@ -12,11 +12,11 @@ pub fn make_blobs(
1212 num_features : usize ,
1313 num_centers : usize ,
1414) -> Dataset < f32 , f32 > {
15- let center_box = Uniform :: from ( -10.0 .. 10.0 ) ;
15+ let center_box = Uniform :: new ( -10.0f32 , 10.0f32 ) . expect ( "Invalid uniform range" ) ;
1616 let cluster_std = 1.0 ;
1717 let mut centers: Vec < Vec < Normal < f32 > > > = Vec :: with_capacity ( num_centers) ;
1818
19- let mut rng = rand:: thread_rng ( ) ;
19+ let mut rng = rand:: rng ( ) ;
2020 for _ in 0 ..num_centers {
2121 centers. push (
2222 ( 0 ..num_features)
@@ -60,7 +60,7 @@ pub fn make_circles(num_samples: usize, factor: f32, noise: f32) -> Dataset<f32,
6060 let linspace_in = linspace ( 0.0 , 2.0 * std:: f32:: consts:: PI , num_samples_in) ;
6161
6262 let noise = Normal :: new ( 0.0 , noise) . unwrap ( ) ;
63- let mut rng = rand:: thread_rng ( ) ;
63+ let mut rng = rand:: rng ( ) ;
6464
6565 let mut x: Vec < f32 > = Vec :: with_capacity ( num_samples * 2 ) ;
6666 let mut y: Vec < f32 > = Vec :: with_capacity ( num_samples) ;
@@ -97,7 +97,7 @@ pub fn make_moons(num_samples: usize, noise: f32) -> Dataset<f32, u32> {
9797 let linspace_in = linspace ( 0.0 , std:: f32:: consts:: PI , num_samples_in) ;
9898
9999 let noise = Normal :: new ( 0.0 , noise) . unwrap ( ) ;
100- let mut rng = rand:: thread_rng ( ) ;
100+ let mut rng = rand:: rng ( ) ;
101101
102102 let mut x: Vec < f32 > = Vec :: with_capacity ( num_samples * 2 ) ;
103103 let mut y: Vec < f32 > = Vec :: with_capacity ( num_samples) ;
0 commit comments