Struct statrs::distribution::MultivariateNormal [−][src]
pub struct MultivariateNormal { /* fields omitted */ }
Expand description
Implements the Multivariate Normal distribution using the “nalgebra” crate for matrix operations
Examples
use statrs::distribution::{MultivariateNormal, Continuous}; use nalgebra::{DVector, DMatrix}; use statrs::statistics::{MeanN, VarianceN}; let mvn = MultivariateNormal::new(vec![0., 0.], vec![1., 0., 0., 1.]).unwrap(); assert_eq!(mvn.mean().unwrap(), DVector::from_vec(vec![0., 0.])); assert_eq!(mvn.variance().unwrap(), DMatrix::from_vec(2, 2, vec![1., 0., 0., 1.])); assert_eq!(mvn.pdf(&DVector::from_vec(vec![1., 1.])), 0.05854983152431917);
Implementations
impl MultivariateNormal
[src]
impl MultivariateNormal
[src]Trait Implementations
impl Clone for MultivariateNormal
[src]
impl Clone for MultivariateNormal
[src]fn clone(&self) -> MultivariateNormal
[src]
fn clone(&self) -> MultivariateNormal
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl<'a> Continuous<&'a Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>, f64> for MultivariateNormal
[src]
impl<'a> Continuous<&'a Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>, f64> for MultivariateNormal
[src]fn pdf(&self, x: &'a DVector<f64>) -> f64
[src]
fn pdf(&self, x: &'a DVector<f64>) -> f64
[src]Calculates the probability density function for the multivariate
normal distribution at x
Formula
(2 * π) ^ (-k / 2) * det(Σ) ^ (1 / 2) * e ^ ( -(1 / 2) * transpose(x - μ) * inv(Σ) * (x - μ))
where μ
is the mean, inv(Σ)
is the precision matrix, det(Σ)
is the determinant
of the covariance matrix, and k
is the dimension of the distribution
impl Debug for MultivariateNormal
[src]
impl Debug for MultivariateNormal
[src]impl Distribution<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]
impl Distribution<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> DVector<f64>
[src]
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> DVector<f64>
[src]Samples from the multivariate normal distribution
Formula
L * Z + μ
where L
is the Cholesky decomposition of the covariance matrix,
Z
is a vector of normally distributed random variables, and
μ
is the mean vector
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
[src]
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
[src]Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
impl Max<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]
impl Max<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]impl MeanN<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]
impl MeanN<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]impl Min<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]
impl Min<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]impl Mode<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]
impl Mode<Matrix<f64, Dynamic, Const<1_usize>, VecStorage<f64, Dynamic, Const<1_usize>>>> for MultivariateNormal
[src]impl PartialEq<MultivariateNormal> for MultivariateNormal
[src]
impl PartialEq<MultivariateNormal> for MultivariateNormal
[src]fn eq(&self, other: &MultivariateNormal) -> bool
[src]
fn eq(&self, other: &MultivariateNormal) -> bool
[src]This method tests for self
and other
values to be equal, and is used
by ==
. Read more
fn ne(&self, other: &MultivariateNormal) -> bool
[src]
fn ne(&self, other: &MultivariateNormal) -> bool
[src]This method tests for !=
.
impl VarianceN<Matrix<f64, Dynamic, Dynamic, VecStorage<f64, Dynamic, Dynamic>>> for MultivariateNormal
[src]
impl VarianceN<Matrix<f64, Dynamic, Dynamic, VecStorage<f64, Dynamic, Dynamic>>> for MultivariateNormal
[src]impl StructuralPartialEq for MultivariateNormal
[src]
Auto Trait Implementations
impl RefUnwindSafe for MultivariateNormal
impl Send for MultivariateNormal
impl Sync for MultivariateNormal
impl Unpin for MultivariateNormal
impl UnwindSafe for MultivariateNormal
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,