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: f64Implementations§
Source§impl NB2Dist
impl NB2Dist
pub fn pmf(&mut self, x: i32) -> f64
pub fn cdf(&mut self, x: i32) -> f64
pub fn per(&mut self, q: f64) -> i32
pub fn ran(&mut self) -> i32
pub fn ranvec(&mut self, n: i32) -> Vec<i32>
pub fn mean(&mut self) -> f64
pub fn var(&mut self) -> f64
pub fn sd(&mut self) -> f64
Auto Trait Implementations§
impl Freeze for NB2Dist
impl RefUnwindSafe for NB2Dist
impl Send for NB2Dist
impl Sync for NB2Dist
impl Unpin for NB2Dist
impl UnwindSafe for NB2Dist
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more