pub enum ScalarSource {
Constant(f64),
Uniform {
low: f64,
high: f64,
},
Histogram(Histogram),
}Expand description
Source distribution for a generated scalar value.
Variants§
Constant(f64)
A deterministic value.
Uniform
A uniform distribution on [low, high).
Histogram(Histogram)
A piecewise-constant histogram distribution.
Implementations§
Source§impl ScalarSource
impl ScalarSource
Sourcepub fn support(&self) -> LadduPhysicsResult<(f64, f64)>
pub fn support(&self) -> LadduPhysicsResult<(f64, f64)>
Validate the source and return the smallest and largest values in its support.
§Errors
Returns LadduPhysicsError when a constant or bound is non-finite, a
uniform interval is empty, or histogram weights are invalid.
§Panics
Panics only if a histogram reports positive total weight without containing any positive-weight bin.
Sourcepub fn sample(
&self,
rng: &mut ProposalRng,
) -> LadduPhysicsResult<ScalarProposalResult>
pub fn sample( &self, rng: &mut ProposalRng, ) -> LadduPhysicsResult<ScalarProposalResult>
Draw a value and inverse-density weight from the source.
§Errors
Returns LadduPhysicsError when the source parameters or histogram
weights are invalid, or a histogram sample cannot be assigned to a bin.
Trait Implementations§
Source§impl Clone for ScalarSource
impl Clone for ScalarSource
Source§fn clone(&self) -> ScalarSource
fn clone(&self) -> ScalarSource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScalarSource
impl Debug for ScalarSource
Source§impl<'de> Deserialize<'de> for ScalarSource
impl<'de> Deserialize<'de> for ScalarSource
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ScalarSource
impl RefUnwindSafe for ScalarSource
impl Send for ScalarSource
impl Sync for ScalarSource
impl Unpin for ScalarSource
impl UnsafeUnpin for ScalarSource
impl UnwindSafe for ScalarSource
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
Mutably borrows from an owned value. Read more
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<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>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.