pub struct MultivariateNormal {
pub mean: Vec<f64>,
pub cov: Vec<Vec<f64>>,
/* private fields */
}Expand description
The multivariate normal distribution N(μ, Σ) (SciPy’s multivariate_normal), for a
positive definite Σ: log f(x) = −½ (d log 2π + log|Σ| + (x − μ)ᵀ Σ⁻¹ (x − μ)), with the
quadratic form computed as ‖L⁻¹(x − μ)‖² from the Cholesky factor Σ = L Lᵀ.
Fields§
§mean: Vec<f64>§cov: Vec<Vec<f64>>Implementations§
Source§impl MultivariateNormal
impl MultivariateNormal
pub fn new(mean: Vec<f64>, cov: Vec<Vec<f64>>) -> Result<Self, ErrorsJSL>
Sourcepub fn new_allow_singular(
mean: Vec<f64>,
cov: Vec<Vec<f64>>,
) -> Result<Self, ErrorsJSL>
pub fn new_allow_singular( mean: Vec<f64>, cov: Vec<Vec<f64>>, ) -> Result<Self, ErrorsJSL>
A normal distribution whose covariance may be singular (SciPy’s
multivariate_normal(mean, cov, allow_singular=True)). The covariance’s eigenvalues
above ε = 10⁶ ε_mach max|λ| define its rank r and range; the density is the r-
dimensional one on the affine support μ + range(Σ), with the pseudo-determinant and
pseudo-inverse, and zero off it.
pub fn dim(&self) -> usize
Sourcepub fn mahalanobis_sq(&self, x: &[f64]) -> f64
pub fn mahalanobis_sq(&self, x: &[f64]) -> f64
The squared Mahalanobis distance (x − μ)ᵀ Σ⁺ (x − μ) (with the pseudo-inverse when the
covariance is singular).
pub fn logpdf(&self, x: &[f64]) -> f64
pub fn pdf(&self, x: &[f64]) -> f64
Source§impl MultivariateNormal
impl MultivariateNormal
Sourcepub fn cdf_between<U: UniformGenerator>(
&self,
lower: Option<&[f64]>,
upper: &[f64],
options: MvCdfOptions,
rng: &mut U,
) -> Result<(f64, f64), ErrorsJSL>
pub fn cdf_between<U: UniformGenerator>( &self, lower: Option<&[f64]>, upper: &[f64], options: MvCdfOptions, rng: &mut U, ) -> Result<(f64, f64), ErrorsJSL>
P(lower < X ≤ upper) (SciPy’s multivariate_normal.cdf(upper, lower_limit=lower);
lower = None for −∞), with the error estimate. One and two dimensions are exact; in
more, Genz’s method: reorder the variables so the most constrained comes first, factor
Σ = L Lᵀ, and write the probability as an integral over the unit cube of a product of
one-dimensional normal probabilities whose limits depend on the earlier variables, then
integrate it with randomised rank-1 lattice rules until the error is below abseps.