pub struct NegativeBinomial { /* private fields */ }Expand description
Negative binomial claim counts in the actuarial parameterization of
Klugman, Panjer & Willmot: mean r β, variance r β (1 + β).
SciPy’s nbinom(n=r, p=1/(1+β)) and R’s dnbinom(size=r, prob=1/(1+β))
are the same distribution.
use prospicio_prob::{Counting, NegativeBinomial};
let n = NegativeBinomial::from_mean_variance(10.0, 30.0).unwrap();
assert!((n.mean() - 10.0).abs() < 1e-12);
assert!((n.variance() - 30.0).abs() < 1e-12);Implementations§
Source§impl NegativeBinomial
impl NegativeBinomial
Sourcepub fn new(r: f64, beta: f64) -> Result<Self>
pub fn new(r: f64, beta: f64) -> Result<Self>
Negative binomial with shape r and scale beta; both must be finite
and positive.
Sourcepub fn from_mean_variance(mean: f64, variance: f64) -> Result<Self>
pub fn from_mean_variance(mean: f64, variance: f64) -> Result<Self>
The negative binomial with this mean and variance; the variance must exceed the mean (over-dispersion).
Trait Implementations§
Source§impl Clone for NegativeBinomial
impl Clone for NegativeBinomial
Source§fn clone(&self) -> NegativeBinomial
fn clone(&self) -> NegativeBinomial
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for NegativeBinomial
Source§impl Counting for NegativeBinomial
impl Counting for NegativeBinomial
Source§impl Debug for NegativeBinomial
impl Debug for NegativeBinomial
Source§impl PartialEq for NegativeBinomial
impl PartialEq for NegativeBinomial
impl StructuralPartialEq for NegativeBinomial
Auto Trait Implementations§
impl Freeze for NegativeBinomial
impl RefUnwindSafe for NegativeBinomial
impl Send for NegativeBinomial
impl Sync for NegativeBinomial
impl Unpin for NegativeBinomial
impl UnsafeUnpin for NegativeBinomial
impl UnwindSafe for NegativeBinomial
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more