1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
pub mod exact;
pub use exact::*;
use crate::{DistributionError, EllipticalError, RandomVariable};
use opensrdk_linear_algebra::*;
use rayon::prelude::*;
pub trait EllipticalParams: RandomVariable {
fn mu(&self) -> &Vec<f64>;
fn x_mu(&self, x: &[f64]) -> Result<Vec<f64>, DistributionError> {
let mu = self.mu();
let n = mu.len();
if n != x.len() {
return Err(DistributionError::InvalidParameters(
EllipticalError::DimensionMismatch.into(),
));
}
let x_mu = x
.par_iter()
.zip(mu.par_iter())
.map(|(&xi, &mui)| xi - mui)
.collect::<Vec<_>>();
Ok(x_mu)
}
fn sigma_inv_mul(&self, v: Matrix) -> Result<Matrix, DistributionError>;
fn lsigma_cols(&self) -> usize;
fn sample(&self, z: Vec<f64>) -> Result<Vec<f64>, DistributionError>;
}