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]

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());

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]

Formats the value using the given formatter. Read more

impl Copy for Geometric
[src]

impl Clone for Geometric
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Geometric
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Distribution<f64> for Geometric
[src]

Generate a random value of T, using rng as the source of randomness.

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]

Calculates the cumulative distribution function for the geometric distribution at x

Formula

This example is not tested
1 - (1 - p) ^ (x + 1)

impl Min<u64> for Geometric
[src]

Returns the minimum value in the domain of the geometric distribution representable by a 64-bit integer

Formula

This example is not tested
1

impl Max<u64> for Geometric
[src]

Returns the maximum value in the domain of the geometric distribution representable by a 64-bit integer

Formula

This example is not tested
2^63 - 1

impl Mean<f64> for Geometric
[src]

Returns the mean of the geometric distribution

Formula

This example is not tested
1 / p

impl Variance<f64> for Geometric
[src]

Returns the standard deviation of the geometric distribution

Formula

This example is not tested
(1 - p) / p^2

Returns the standard deviation of the geometric distribution

Remarks

Returns NAN if p is 1

Formula

This example is not tested
sqrt(1 - p) / p

impl Entropy<f64> for Geometric
[src]

Returns the entropy of the geometric distribution

Formula

This example is not tested
(-(1 - p) * log_2(1 - p) - p * log_2(p)) / p

impl Skewness<f64> for Geometric
[src]

Returns the skewness of the geometric distribution

Formula

This example is not tested
(2 - p) / sqrt(1 - p)

impl Mode<u64> for Geometric
[src]

Returns the mode of the geometric distribution

Formula

This example is not tested
1

impl Median<f64> for Geometric
[src]

Returns the median of the geometric distribution

Remarks

Returns 1 if p is 1

Formula

This example is not tested
ceil(-1 / log_2(1 - p))

impl Discrete<u64, f64> for Geometric
[src]

Calculates the probability mass function for the geometric distribution at x

Formula

This example is not tested
(1 - p)^(x - 1) * p

Calculates the log probability mass function for the geometric distribution at x

Formula

This example is not tested
ln((1 - p)^(x - 1) * p)

Auto Trait Implementations

impl Send for Geometric

impl Sync for Geometric