pub struct Geometric { /* private fields */ }Implementations§
Source§impl Geometric
impl Geometric
Sourcepub fn new(p: f64) -> Result<Self, GeometricError>
pub fn new(p: f64) -> Result<Self, GeometricError>
Create a new geometric distribution
Sourcepub fn new_unchecked(p: f64) -> Self
pub fn new_unchecked(p: f64) -> Self
Creates a new Geometric without checking whether the parameter is valid.
Sourcepub fn set_p(&mut self, p: f64) -> Result<(), GeometricError>
pub fn set_p(&mut self, p: f64) -> Result<(), GeometricError>
Set the p parameter
§Example
let mut geom = Geometric::new(0.2).unwrap();
geom.set_p(0.5).unwrap();
assert_eq!(geom.p(), 0.5);Will error for invalid values
assert!(geom.set_p(0.5).is_ok());
assert!(geom.set_p(1.0).is_ok());
assert!(geom.set_p(0.0).is_err());
assert!(geom.set_p(-1.0).is_err());
assert!(geom.set_p(1.1).is_err());
assert!(geom.set_p(f64::INFINITY).is_err());
assert!(geom.set_p(f64::NEG_INFINITY).is_err());
assert!(geom.set_p(f64::NAN).is_err());Sourcepub fn set_p_unchecked(&mut self, p: f64)
pub fn set_p_unchecked(&mut self, p: f64)
Set p without input validation
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Geometric
impl<'de> Deserialize<'de> for Geometric
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
Source§impl<X> DiscreteDistr<X> for Geometric
impl<X> DiscreteDistr<X> for Geometric
Source§impl<X> HasDensity<X> for Geometric
impl<X> HasDensity<X> for Geometric
Source§impl Parameterized for Geometric
impl Parameterized for Geometric
type Parameters = GeometricParameters
fn emit_params(&self) -> Self::Parameters
fn from_params(params: Self::Parameters) -> Self
fn map_params(&self, f: impl Fn(Self::Parameters) -> Self::Parameters) -> Self
Source§impl<X> Sampleable<X> for Geometric
impl<X> Sampleable<X> for Geometric
Auto Trait Implementations§
impl !Freeze for Geometric
impl RefUnwindSafe for Geometric
impl Send for Geometric
impl Sync for Geometric
impl Unpin for Geometric
impl UnwindSafe for Geometric
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,
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>
Converts
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>
Converts
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<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.