Skip to main content

GeoDist

Struct GeoDist 

Source
pub struct GeoDist {
    pub p: f64,
}
Expand description

Struct for the geometric distribution X ~ Geo(p) where X = the number of failures prior to observing the first success.

§Parameters

  • p = probability of success (0 < p <= 1)

§Support

  • x = 0,1,2,...

§Example

Suppose X ~ Geo(p=0.2). Use

use ruststat::GeoDist;
let mut mygeo = GeoDist{p:0.2};
println!("probability mass function: {}", mygeo.pmf(8));
println!("cumulative distribution function: {}", mygeo.cdf(8));
println!("percentile: {}", mygeo.per(0.99));
println!("random: {}", mygeo.ran());
println!("Random vector: {:?}", mygeo.ranvec(5));
println!("mean: {}", mygeo.mean());
println!("variance: {}", mygeo.var());
println!("standard deviation: {}", mygeo.sd());

Fields§

§p: f64

Implementations§

Source§

impl GeoDist

Source

pub fn pmf(&mut self, x: u64) -> f64

Source

pub fn cdf(&mut self, x: u64) -> f64

Source

pub fn per(&mut self, q: f64) -> u64

Source

pub fn ran(&mut self) -> u64

Source

pub fn ranvec(&mut self, n: u64) -> Vec<u64>

Source

pub fn mean(&mut self) -> f64

Source

pub fn var(&mut self) -> f64

Source

pub fn sd(&mut self) -> f64

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.