How can I generate a random number ranging from negative infinity to 2.0?
Here is a snip of the code which I wrote to achieve it:
let neginf = std::f64::NEG_INFINITY;
let mut rng = rand::thread_rng();
let normal = Uniform::new(neginf, 2.0);
let v = normal.sample(&mut rng);
The error message which I get is:
thread 'main' panicked at 'Uniform::new: range overflow'
I'll be grateful for any hints.
Aucun commentaire:
Enregistrer un commentaire