I can't figure out why I get an error on this code:
extern crate rand;
extern crate statrs;
use rand::distributions::Distribution;
use statrs::distribution::Beta;
fn main() {
let beta = Beta::new(1.0, 2.0).unwrap();
beta.sample(&mut rand::thread_rng());
}
The error message I get is:
error[E0599]: no method named `sample` found for type `statrs::distribution::Beta` in the current scope
--> src/main.rs:9:10
|
9 | beta.sample(&mut rand::thread_rng());
| ^^^^^^
|
= help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
|
4 | use rand::distributions::Distribution;
|
I've added the exact use that it suggests, but the error stays. I've now for the better part of an hour tried taking everything I can think of in scope, out of scope, writing the use
statements this way and that and I can't figure it out.
I checked both the source and the documentation of statrs and the sample()
function implemented in the Distribution
trait.
What do I need to change so I can sample random values from the Beta
function?