Struct mathru::stats::distrib::Bernoulli

source ·
pub struct Bernoulli { /* private fields */ }
Expand description

Bernoulli distribution

Fore more information: https://en.wikipedia.org/wiki/Bernoulli_distribution

Implementations

Create a probability distribution with p(X=1) = p

Arguments
  • p Probability that random varibale X=1, 0.0 <= p <= 1.0
Panics

if p < 0 || p > 1.0

Example
extern crate mathru;
use mathru::stats::distrib::Bernoulli;

let distrib: Bernoulli = Bernoulli::new(0.2);

Trait Implementations

Probability mass function of the Bernoulli distribution

Arguments
  • x Random variable x ∈ {0, 1}
Panics

if x ∉ {0, 1}

Example
extern crate mathru;
use mathru::stats::distrib::{Discrete, Bernoulli};

let distrib: Bernoulli = Bernoulli::new(0.2);
let x: u8 = 0;
let p: f64 = distrib.pmf(x);

Cumulative distribution function of the Bernoulli distribution

Arguments
  • x Random variable x ∈ {0, 1}
Example
extern crate mathru;
use mathru::stats::distrib::{Discrete, Bernoulli};

let distrib: Bernoulli = Bernoulli::new(0.2);
let x: f64 = 0.4;
let p: f64 = distrib.cdf(x);

Expected value

Example
extern crate mathru;
use mathru::stats::distrib::{Discrete, Bernoulli};

let distrib: Bernoulli = Bernoulli::new(0.2);
let mean: f64 = distrib.mean();

Variance

Example
extern crate mathru;
use mathru::stats::distrib::{Discrete, Bernoulli};

let distrib: Bernoulli = Bernoulli::new(0.2);
let var: f64 = distrib.variance();

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.