pub enum ParameterConstraint {
Real,
Positive,
UnitInterval,
Bounded {
lower: f64,
upper: f64,
},
Simplex {
dim: usize,
},
LowerBounded {
lower: f64,
},
UpperBounded {
upper: f64,
},
}Expand description
Type of parameter constraint and its corresponding transformation
Variants§
Real
Unconstrained real-valued parameter (identity transform)
Positive
Positive parameter (log transform: unconstrained -> positive)
UnitInterval
Parameter on (0, 1) (logistic transform)
Bounded
Parameter on (lower, upper) (scaled logistic transform)
Simplex
Simplex constraint (sum to 1) using stick-breaking transform
LowerBounded
Lower-bounded parameter (shifted log transform)
UpperBounded
Upper-bounded parameter (reflected log transform)
Implementations§
Source§impl ParameterConstraint
impl ParameterConstraint
Sourcepub fn forward(&self, unconstrained: f64) -> f64
pub fn forward(&self, unconstrained: f64) -> f64
Transform from unconstrained to constrained space
Sourcepub fn inverse(&self, constrained: f64) -> Result<f64>
pub fn inverse(&self, constrained: f64) -> Result<f64>
Transform from constrained to unconstrained space
Sourcepub fn log_det_jacobian(&self, unconstrained: f64) -> f64
pub fn log_det_jacobian(&self, unconstrained: f64) -> f64
Compute the log absolute determinant of the Jacobian of the forward transform
This is needed for correcting the density when transforming from unconstrained to constrained space: p(constrained) = p_unconstrained(inverse(constrained)) * |det J^{-1}|
Equivalently, for the ELBO in unconstrained space: log p(forward(eta)) + log |det J_forward(eta)|
Trait Implementations§
Source§impl Clone for ParameterConstraint
impl Clone for ParameterConstraint
Source§fn clone(&self) -> ParameterConstraint
fn clone(&self) -> ParameterConstraint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ParameterConstraint
impl RefUnwindSafe for ParameterConstraint
impl Send for ParameterConstraint
impl Sync for ParameterConstraint
impl Unpin for ParameterConstraint
impl UnsafeUnpin for ParameterConstraint
impl UnwindSafe for ParameterConstraint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.