Struct statrs::distribution::Geometric [−][src]
Implements the Geometric distribution
Examples
use statrs::distribution::{Geometric, Discrete}; use statrs::statistics::Mean; let n = Geometric::new(0.3).unwrap(); assert_eq!(n.mean(), 1.0 / 0.3); assert_eq!(n.pmf(1), 0.3); assert_eq!(n.pmf(2), 0.21);
Implementations
impl Geometric
[src]
pub fn new(p: f64) -> Result<Geometric>
[src]
Constructs a new shifted geometric distribution with a probability
of p
Errors
Returns an error if p
is not in (0, 1]
Examples
use statrs::distribution::Geometric; let mut result = Geometric::new(0.5); assert!(result.is_ok()); result = Geometric::new(0.0); assert!(result.is_err());
pub fn p(&self) -> f64
[src]
Returns the probability p
of the geometric
distribution
Examples
use statrs::distribution::Geometric; let n = Geometric::new(0.5).unwrap(); assert_eq!(n.p(), 0.5);
Trait Implementations
impl Clone for Geometric
[src]
impl Copy for Geometric
[src]
impl Debug for Geometric
[src]
impl Discrete<u64, f64> for Geometric
[src]
fn pmf(&self, x: u64) -> f64
[src]
Calculates the probability mass function for the geometric
distribution at x
Formula
(1 - p)^(x - 1) * p
fn ln_pmf(&self, x: u64) -> f64
[src]
Calculates the log probability mass function for the geometric
distribution at x
Formula
ln((1 - p)^(x - 1) * p)
impl Distribution<f64> for Geometric
[src]
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
[src]
pub fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
[src]
R: Rng,
impl Entropy<f64> for Geometric
[src]
fn entropy(&self) -> f64
[src]
Returns the entropy of the geometric distribution
Formula
(-(1 - p) * log_2(1 - p) - p * log_2(p)) / p
impl Max<u64> for Geometric
[src]
fn max(&self) -> u64
[src]
Returns the maximum value in the domain of the geometric distribution representable by a 64-bit integer
Formula
2^63 - 1
impl Mean<f64> for Geometric
[src]
impl Median<f64> for Geometric
[src]
impl Min<u64> for Geometric
[src]
fn min(&self) -> u64
[src]
Returns the minimum value in the domain of the geometric distribution representable by a 64-bit integer
Formula
1
impl Mode<u64> for Geometric
[src]
impl PartialEq<Geometric> for Geometric
[src]
impl Skewness<f64> for Geometric
[src]
impl StructuralPartialEq for Geometric
[src]
impl Univariate<u64, f64> for Geometric
[src]
fn cdf(&self, x: f64) -> f64
[src]
Calculates the cumulative distribution function for the geometric
distribution at x
Formula
1 - (1 - p) ^ (x + 1)
impl Variance<f64> for Geometric
[src]
Auto Trait Implementations
impl RefUnwindSafe for Geometric
impl Send for Geometric
impl Sync for Geometric
impl Unpin for Geometric
impl UnwindSafe for Geometric
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,