[−][src]Struct rv::dist::NormalInvWishart
Common conjugate prior on the μ and Σ parameters in the Multivariate Gaussian, Ν(μ, Σ)
Ν(μ, Σ) ~ NIW(μ0, κ0, ν, Ψ) implies μ ~ N(μ0, Σ/k0) and Σ ~ W-1(Ψ, ν)
Example
Draw a Multivariate Gaussian from GIW
use nalgebra::{DMatrix, DVector}; use rv::prelude::*; let mu = DVector::zeros(3); let k = 1.0; let df = 3; let scale = DMatrix::identity(3, 3); let niw = NormalInvWishart::new(mu, k, df, scale).unwrap(); let mut rng = rand::thread_rng(); let mvg: MvGaussian = niw.draw(&mut rng);
Implementations
impl NormalInvWishart
[src]
pub fn new(
mu: DVector<f64>,
k: f64,
df: usize,
scale: DMatrix<f64>
) -> Result<Self, NormalInvWishartError>
[src]
mu: DVector<f64>,
k: f64,
df: usize,
scale: DMatrix<f64>
) -> Result<Self, NormalInvWishartError>
Create a new NormalInvWishart
distribution
Arguments
- mu: The mean of μ, μ0
- k: A scale factor on Σ, κ0
- df: The degrees of freedom, ν > |μ| - 1
- scale The positive-definite scale matrix, Ψ
pub fn new_unchecked(
mu: DVector<f64>,
k: f64,
df: usize,
scale: DMatrix<f64>
) -> Self
[src]
mu: DVector<f64>,
k: f64,
df: usize,
scale: DMatrix<f64>
) -> Self
Creates a new NormalInvWishart without checking whether the parameters are valid.
pub fn ndims(&self) -> usize
[src]
Get the number of dimensions
pub fn mu(&self) -> &DVector<f64>
[src]
Get a reference to the mu vector
pub fn k(&self) -> f64
[src]
Get the k parameter
pub fn set_k(&mut self, k: f64) -> Result<(), NormalInvWishartError>
[src]
Set the value of k
pub fn set_k_unchecked(&mut self, k: f64)
[src]
Set the value of k without input validation
pub fn df(&self) -> usize
[src]
Get the degrees of freedom, df
pub fn set_df(&mut self, df: usize) -> Result<(), NormalInvWishartError>
[src]
Set the value of df
pub fn set_df_unchecked(&mut self, df: usize)
[src]
Set the value of df without input validation
pub fn scale(&self) -> &DMatrix<f64>
[src]
Get a reference to the scale matrix
pub fn set_scale(
&mut self,
scale: DMatrix<f64>
) -> Result<(), NormalInvWishartError>
[src]
&mut self,
scale: DMatrix<f64>
) -> Result<(), NormalInvWishartError>
Set the scale parameter
pub fn set_scale_unnchecked(&mut self, scale: DMatrix<f64>)
[src]
pub fn set_mu(&mut self, mu: DVector<f64>) -> Result<(), NormalInvWishartError>
[src]
Set the scale parameter
pub fn set_mu_unchecked(&mut self, mu: DVector<f64>)
[src]
Trait Implementations
impl Clone for NormalInvWishart
[src]
fn clone(&self) -> NormalInvWishart
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl ConjugatePrior<Matrix<f64, Dynamic, U1, VecStorage<f64, Dynamic, U1>>, MvGaussian> for NormalInvWishart
[src]
type Posterior = NormalInvWishart
fn posterior(
&self,
x: &DataOrSuffStat<'a, DVector<f64>, MvGaussian>
) -> NormalInvWishart
[src]
&self,
x: &DataOrSuffStat<'a, DVector<f64>, MvGaussian>
) -> NormalInvWishart
fn ln_m(&self, x: &DataOrSuffStat<'a, DVector<f64>, MvGaussian>) -> f64
[src]
fn ln_pp(
&self,
y: &DVector<f64>,
x: &DataOrSuffStat<'a, DVector<f64>, MvGaussian>
) -> f64
[src]
&self,
y: &DVector<f64>,
x: &DataOrSuffStat<'a, DVector<f64>, MvGaussian>
) -> f64
fn m(&self, x: &DataOrSuffStat<X, Fx>) -> f64
[src]
fn pp(&self, y: &X, x: &DataOrSuffStat<X, Fx>) -> f64
[src]
impl ContinuousDistr<MvGaussian> for NormalInvWishart
[src]
impl Debug for NormalInvWishart
[src]
impl Display for NormalInvWishart
[src]
impl<'_> From<&'_ NormalInvWishart> for String
[src]
fn from(niw: &NormalInvWishart) -> String
[src]
impl PartialEq<NormalInvWishart> for NormalInvWishart
[src]
fn eq(&self, other: &NormalInvWishart) -> bool
[src]
fn ne(&self, other: &NormalInvWishart) -> bool
[src]
impl Rv<MvGaussian> for NormalInvWishart
[src]
fn ln_f(&self, x: &MvGaussian) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> MvGaussian
[src]
fn f(&self, x: &X) -> f64
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<X>
[src]
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl StructuralPartialEq for NormalInvWishart
[src]
impl Support<MvGaussian> for NormalInvWishart
[src]
fn supports(&self, x: &MvGaussian) -> bool
[src]
Auto Trait Implementations
impl RefUnwindSafe for NormalInvWishart
impl Send for NormalInvWishart
impl Sync for NormalInvWishart
impl Unpin for NormalInvWishart
impl UnwindSafe for NormalInvWishart
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Fx, X> ContinuousDistr<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: ContinuousDistr<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: ContinuousDistr<X>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<Fx, X> Rv<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Rv<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Rv<X>,
fn ln_f(&Self, &X) -> f64
[src]
fn f(&Self, &X) -> f64
[src]
fn draw<R>(&Self, &mut R) -> X where
R: Rng,
[src]
R: Rng,
fn sample<R>(&Self, usize, &mut R) -> Vec<X> where
R: Rng,
[src]
R: Rng,
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<Fx, X> Support<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Support<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Support<X>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,