NB2Dist

Struct NB2Dist 

Source
pub struct NB2Dist {
    pub r: i32,
    pub p: f64,
}
Expand description

Struct for the negative binomial distribution X ~ NB(r,p) where X = the trial on which the rth success is observed.

§Parameters

  • r = r,r+1,r+2,...
  • p = probability of success (0 < p <= 1)

§Support

  • x = r,r+1,r+2,...

§Example

Suppose X ~ NB(r=4,p=0.2). Use

use ruststat::NB2Dist;
let mut mynb = NB2Dist{r:4, p:0.2};
println!("P(X=6): {}", mynb.pmf(6));
println!("P(X<=6): {}", mynb.cdf(6));
println!("99th percentile: {}", mynb.per(0.99));
println!("Random draw: {}", mynb.ran());
println!("Random vector: {:?}", mynb.ranvec(5));
println!("Mean: {}", mynb.mean());
println!("Variance: {}", mynb.var());
println!("Standard deviation: {}", mynb.sd());

Fields§

§r: i32§p: f64

Implementations§

Source§

impl NB2Dist

Source

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

Source

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

Source

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

Source

pub fn ran(&mut self) -> i32

Source

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

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V