Skip to main content

Prior

Enum Prior 

Source
pub enum Prior {
    Uniform {
        low: f64,
        high: f64,
    },
    Gaussian {
        mean: f64,
        std: f64,
    },
    Laplace {
        mu: f64,
        b: f64,
    },
    Jeffreys,
    Dirichlet {
        alpha: Vec<f64>,
    },
    Beta {
        alpha: f64,
        beta: f64,
    },
    Gamma {
        shape: f64,
        rate: f64,
    },
}
Expand description

Supported prior distribution families.

Variants§

§

Uniform

Uniform prior on [low, high].

Fields

§low: f64

Lower bound.

§high: f64

Upper bound.

§

Gaussian

Gaussian (normal) prior N(mean, std²).

Fields

§mean: f64

Prior mean.

§std: f64

Prior standard deviation.

§

Laplace

Laplace (double-exponential) prior with location μ and scale b.

Fields

§mu: f64

Location parameter.

§b: f64

Scale parameter (b > 0).

§

Jeffreys

Jeffreys (improper) scale prior ∝ 1/θ for θ > 0.

§

Dirichlet

Dirichlet prior over a simplex with concentration parameters α.

Fields

§alpha: Vec<f64>

Concentration parameters (all positive).

§

Beta

Beta prior Beta(alpha, beta) on [0, 1].

Fields

§alpha: f64

Shape parameter α > 0.

§beta: f64

Shape parameter β > 0.

§

Gamma

Gamma prior Gamma(shape, rate) on (0, ∞).

Fields

§shape: f64

Shape k > 0.

§rate: f64

Rate λ > 0.

Implementations§

Source§

impl Prior

Source

pub fn log_density(&self, theta: f64) -> f64

Returns the log prior density log p(θ) for a scalar parameter θ.

Returns f64::NEG_INFINITY when θ is outside the support.

Source

pub fn dirichlet_log_density(&self, x: &[f64]) -> f64

Returns the log density of a Dirichlet prior for a probability vector x.

Returns f64::NEG_INFINITY when the dimensions do not match.

Source

pub fn sample(&self, seed: u64) -> Option<f64>

Samples from the prior using the given RNG seed.

Returns None for improper priors (Jeffreys, Dirichlet) where scalar sampling is not defined without additional context.

Trait Implementations§

Source§

impl Clone for Prior

Source§

fn clone(&self) -> Prior

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Prior

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Prior

§

impl RefUnwindSafe for Prior

§

impl Send for Prior

§

impl Sync for Prior

§

impl Unpin for Prior

§

impl UnsafeUnpin for Prior

§

impl UnwindSafe for Prior

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.