pub struct Dispersion { /* private fields */ }Expand description
Dispersion contract used by inferential covariance and reference distributions.
This type lives in gam-problem; re-exported here so model result APIs and
existing engine code name the same neutral contract.
A validated response-level dispersion phi.
A known/fixed dispersion is finite and strictly positive. An estimated dispersion is finite and non-negative: zero is a meaningful boundary result for an exact fit, but any operation that divides by it must explicitly fail. The distinction prevents a zero estimate from being silently promoted to a tiny positive fixed scale.
Implementations§
Source§impl Dispersion
impl Dispersion
Sourcepub const UNIT: Dispersion
pub const UNIT: Dispersion
Exact unit fixed dispersion for fixed-scale likelihoods.
Sourcepub const ZERO_ESTIMATE: Dispersion
pub const ZERO_ESTIMATE: Dispersion
Exact boundary estimate produced by a zero-residual fit.
Sourcepub fn known(phi: f64) -> Result<Dispersion, DispersionError>
pub fn known(phi: f64) -> Result<Dispersion, DispersionError>
Construct a finite, strictly-positive fixed dispersion.
Sourcepub fn estimated(phi: f64) -> Result<Dispersion, DispersionError>
pub fn estimated(phi: f64) -> Result<Dispersion, DispersionError>
Construct a finite, non-negative estimated dispersion.
Sourcepub fn from_reciprocal(
value: f64,
estimated: bool,
) -> Result<Dispersion, DispersionError>
pub fn from_reciprocal( value: f64, estimated: bool, ) -> Result<Dispersion, DispersionError>
Construct a dispersion from a finite positive precision/shape.
This checks the division itself; a positive subnormal denominator whose reciprocal overflows is rejected instead of being floored.
pub const fn phi(self) -> f64
pub const fn is_estimated(self) -> bool
Sourcepub const fn is_zero_estimate(self) -> bool
pub const fn is_zero_estimate(self) -> bool
Whether this is the exact, validated boundary estimate phi = 0.
Sourcepub fn reciprocal(self) -> Result<f64, DispersionError>
pub fn reciprocal(self) -> Result<f64, DispersionError>
Return 1 / phi, rejecting the exact boundary and overflow.
Sourcepub fn rescale_estimate(
&mut self,
multiplier: f64,
) -> Result<bool, DispersionError>
pub fn rescale_estimate( &mut self, multiplier: f64, ) -> Result<bool, DispersionError>
Rescale an estimated dispersion in place.
Fixed dispersions are left unchanged and return Ok(false). The product
is checked before mutation so this operation is atomic on error.
Trait Implementations§
Source§impl Clone for Dispersion
impl Clone for Dispersion
Source§fn clone(&self) -> Dispersion
fn clone(&self) -> Dispersion
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Dispersion
Source§impl Debug for Dispersion
impl Debug for Dispersion
Source§impl<'de> Deserialize<'de> for Dispersion
impl<'de> Deserialize<'de> for Dispersion
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Dispersion, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Dispersion, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Dispersion
impl PartialEq for Dispersion
Source§impl Serialize for Dispersion
impl Serialize for Dispersion
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Dispersion
Source§impl TryFrom<DispersionWire> for Dispersion
impl TryFrom<DispersionWire> for Dispersion
Source§type Error = DispersionError
type Error = DispersionError
Source§fn try_from(
value: DispersionWire,
) -> Result<Dispersion, <Dispersion as TryFrom<DispersionWire>>::Error>
fn try_from( value: DispersionWire, ) -> Result<Dispersion, <Dispersion as TryFrom<DispersionWire>>::Error>
Auto Trait Implementations§
impl Freeze for Dispersion
impl RefUnwindSafe for Dispersion
impl Send for Dispersion
impl Sync for Dispersion
impl Unpin for Dispersion
impl UnsafeUnpin for Dispersion
impl UnwindSafe for Dispersion
Blanket Implementations§
impl<T> Allocation for T
impl<T> Boilerplate for T
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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,
impl<T> Scalar for T
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.