## distributions.NegativeBinomial


Negative binomial claim counts: mean `r * beta`, variance


Usage


``` python
distributions.NegativeBinomial()
```


`r * beta * (1 + beta)` (Klugman, Panjer & Willmot).

SciPy's `nbinom(n=r, p=1/(1+beta))` is the same distribution.


## Parameters


`r: float`  
Shape; must be positive.

`beta: float`  
Scale; must be positive.


## Raises


`ValueError`  
If [r](distributions.NegativeBinomial.md#prospicio.distributions.NegativeBinomial.r) or [beta](risk.Gpd.md#prospicio.risk.Gpd.beta) is not positive and finite.


## Examples

``` python
>>> from prospicio.distributions import NegativeBinomial
>>> n = NegativeBinomial.from_mean_variance(10.0, 30.0)
>>> round(n.variance(), 9)
```

30.0


## Attributes

| Name | Description |
|----|----|
| [beta](#beta) | Scale [beta](risk.Gpd.md#prospicio.risk.Gpd.beta). |
| [r](#r) | Shape [r](distributions.NegativeBinomial.md#prospicio.distributions.NegativeBinomial.r). |

------------------------------------------------------------------------


#### beta


Scale [beta](risk.Gpd.md#prospicio.risk.Gpd.beta).


`beta: float`


------------------------------------------------------------------------


#### r


Shape [r](distributions.NegativeBinomial.md#prospicio.distributions.NegativeBinomial.r).


`r: float`


## Methods

| Name | Description |
|----|----|
| [cdf()](#cdf) | `P(N <= k)`. |
| [from_mean_variance()](#from_mean_variance) | The negative binomial with this mean and variance. |
| [mean()](#mean) | Mean of the claim count. |
| [pmf()](#pmf) | `P(N = k)`. |
| [quantile()](#quantile) | Smallest `k` with `P(N <= k) >= p`. |
| [sample()](#sample) | [n](distributions.Binomial.md#prospicio.distributions.Binomial.n) claim counts from stream `stream` of the generator keyed by |
| [variance()](#variance) | Variance of the claim count. |

------------------------------------------------------------------------


#### cdf()


`P(N <= k)`.


Usage


``` python
cdf(k)
```


##### Parameters


`k: int`  


##### Returns


`float`  


------------------------------------------------------------------------


#### from_mean_variance()


The negative binomial with this mean and variance.


Usage


``` python
from_mean_variance(mean, variance)
```


##### Parameters


`mean: float`  
Must be positive.

`variance: float`  
Must exceed the mean.


##### Returns


`NegativeBinomial`  


##### Raises


`ValueError`  
If the mean is not positive or the variance does not exceed it.


------------------------------------------------------------------------


#### mean()


Mean of the claim count.


Usage


``` python
mean()
```


##### Returns


`float`  


------------------------------------------------------------------------


#### pmf()


`P(N = k)`.


Usage


``` python
pmf(k)
```


##### Parameters


`k: int`  


##### Returns


`float`  


------------------------------------------------------------------------


#### quantile()


Smallest `k` with `P(N <= k) >= p`.


Usage


``` python
quantile(p)
```


##### Parameters


`p: float`  
Probability in `[0, 1)`.


##### Returns


`int`  


##### Raises


`ValueError`  
If [p](models.Elpd.md#prospicio.models.Elpd.p) is outside `[0, 1]`.


------------------------------------------------------------------------


#### sample()


[n](distributions.Binomial.md#prospicio.distributions.Binomial.n) claim counts from stream `stream` of the generator keyed by


Usage


``` python
sample(n, seed, stream=0)
```


[seed](aggregate.EventSet.md#prospicio.aggregate.EventSet.seed).


##### Parameters


`n: int`  

`seed: int`  

`stream: int = ``0`  


##### Returns


`list of int`  


------------------------------------------------------------------------


#### variance()


Variance of the claim count.


Usage


``` python
variance()
```


##### Returns


`float`
