statrs-dev / statrs

Statistical computation library for Rust
https://docs.rs/statrs/latest/statrs/
MIT License
546 stars 78 forks source link

Example code contains errors #181

Closed EliaBernardi closed 2 months ago

EliaBernardi commented 1 year ago

I am struggling with MultivariateNormal creation. I read the documentation https://docs.rs/statrs/0.13.0/statrs/distribution/struct.MultivariateNormal.html and tried to copy and paste the example code, but it won't compile because it contains errors.

I'm using statrs = "0.16.0" nalgebra = "0.32.1"

even though I tried with many different version of the libraries (suggested by the error) I can't make it work.

EliaBernardi commented 1 year ago

This code works


let mvn = MultivariateNormal::new(vec![0., 0.], vec![1., 0., 0., 1.]).unwrap();
let a =  DVector::from(vec![1.,1.]);
println!("PDF : {:?}",mvn.pdf(&a));

I used these versions of the libraries: statrs = "0.14.0" nalgebra = "0.26.2"

YeungOnion commented 2 months ago

I think it would be good to document that the API for MultivariateNormal introduces a public dependency for nalgebra::DVector, but what would you consider this issue's status?

YeungOnion commented 2 months ago

closing for now, started discussing this issue and related in broader scope in #225