Struct statrs::distribution::Geometric [−][src]
pub struct Geometric { /* fields omitted */ }
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);
Methods
impl Geometric
[src]
impl Geometric
pub fn new(p: f64) -> Result<Geometric>
[src]
pub fn new(p: f64) -> Result<Geometric>
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]
pub fn p(&self) -> f64
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 Debug for Geometric
[src]
impl Debug for Geometric
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Copy for Geometric
[src]
impl Copy for Geometric
impl Clone for Geometric
[src]
impl Clone for Geometric
fn clone(&self) -> Geometric
[src]
fn clone(&self) -> Geometric
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Geometric
[src]
impl PartialEq for Geometric
fn eq(&self, other: &Geometric) -> bool
[src]
fn eq(&self, other: &Geometric) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Geometric) -> bool
[src]
fn ne(&self, other: &Geometric) -> bool
This method tests for !=
.
impl Distribution<f64> for Geometric
[src]
impl Distribution<f64> for Geometric
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
[src]
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
Generate a random value of T
, using rng
as the source of randomness.
fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,
[src]
fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as the source of randomness. Read more
impl Univariate<u64, f64> for Geometric
[src]
impl Univariate<u64, f64> for Geometric
fn cdf(&self, x: f64) -> f64
[src]
fn cdf(&self, x: f64) -> f64
Calculates the cumulative distribution function for the geometric
distribution at x
Formula
1 - (1 - p) ^ (x + 1)
impl Min<u64> for Geometric
[src]
impl Min<u64> for Geometric
fn min(&self) -> u64
[src]
fn min(&self) -> u64
Returns the minimum value in the domain of the geometric distribution representable by a 64-bit integer
Formula
1
impl Max<u64> for Geometric
[src]
impl Max<u64> for Geometric
fn max(&self) -> u64
[src]
fn max(&self) -> u64
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 Mean<f64> for Geometric
impl Variance<f64> for Geometric
[src]
impl Variance<f64> for Geometric
fn variance(&self) -> f64
[src]
fn variance(&self) -> f64
Returns the standard deviation of the geometric distribution
Formula
(1 - p) / p^2
fn std_dev(&self) -> f64
[src]
fn std_dev(&self) -> f64
impl Entropy<f64> for Geometric
[src]
impl Entropy<f64> for Geometric
fn entropy(&self) -> f64
[src]
fn entropy(&self) -> f64
Returns the entropy of the geometric distribution
Formula
(-(1 - p) * log_2(1 - p) - p * log_2(p)) / p
impl Skewness<f64> for Geometric
[src]
impl Skewness<f64> for Geometric
fn skewness(&self) -> f64
[src]
fn skewness(&self) -> f64
Returns the skewness of the geometric distribution
Formula
(2 - p) / sqrt(1 - p)
impl Mode<u64> for Geometric
[src]
impl Mode<u64> for Geometric
impl Median<f64> for Geometric
[src]
impl Median<f64> for Geometric
impl Discrete<u64, f64> for Geometric
[src]
impl Discrete<u64, f64> for Geometric
fn pmf(&self, x: u64) -> f64
[src]
fn pmf(&self, x: u64) -> f64
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]
fn ln_pmf(&self, x: u64) -> f64
Calculates the log probability mass function for the geometric
distribution at x
Formula
ln((1 - p)^(x - 1) * p)