## distributions.SizeOfLoss


A severity read from a size-of-loss table: claim counts and loss totals


Usage

``` python
distributions.SizeOfLoss()
```


by size band, as Werner and Modlin's *Basic Ratemaking* chapter 11 prices increased limits and deductibles. Each band's claims sit at the band's average, so the limited expected value is exact at every band edge, `(losses below b + b * claims above b) / claims`, and [ilf](pricing.ilf.md#prospicio.pricing.ilf), [loss_elimination_ratio](pricing.loss_elimination_ratio.md#prospicio.pricing.loss_elimination_ratio) and every layer function take it. The mean is the table's; the variance sees only the band averages.


## Parameters


`bounds: list of float`  
`len(counts) + 1` band bounds, from 0 or above, strictly increasing; the last may be `inf`.

`counts: list of float`  
Claims in each band.

`losses: list of float`  
Their loss total. Each band's average must lie within its bounds (a claim capped at a policy limit belongs to the band below the limit).


## Raises


`ValueError`  
If the lengths differ, the bounds do not increase, or a band's average lies outside its bounds.


## Examples

``` python
>>> from prospicio.distributions import SizeOfLoss
>>> from prospicio.pricing import ilf
>>> t = SizeOfLoss([0, 100e3, 250e3, 500e3, 1e6], [2324, 1923, 680, 73],
...                [117_629_223, 307_599_929, 222_793_514, 43_047_470])
>>> round(t.lev(100e3)), round(ilf(t, 250e3, 100e3), 2)
```

(77046, 1.59)


## Attributes

| Name | Description |
|----|----|
| [bounds](#bounds) | The band bounds. |
| [claims](#claims) | The number of claims. |
| [counts](#counts) | The claim counts by band. |
| [losses](#losses) | The loss totals by band. |

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


#### bounds


The band bounds.


`bounds: list[float]`


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


#### claims


The number of claims.


`claims: float`


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


#### counts


The claim counts by band.


`counts: list[float]`


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


#### losses


The loss totals by band.


`losses: list[float]`


## Methods

| Name | Description |
|----|----|
| [cdf()](#cdf) | Distribution function `P(X <= x)`. |
| [layer()](#layer) | Expected loss to the layer [limit](pricing.Quote.md#prospicio.pricing.Quote.limit) xs [attachment](reinsurance.Layer.md#prospicio.reinsurance.Layer.attachment). |
| [layer_second_moment()](#layer_second_moment) | Second moment of the loss to the layer [limit](pricing.Quote.md#prospicio.pricing.Quote.limit) xs |
| [layer_third_moment()](#layer_third_moment) | Third moment of the loss to the layer [limit](pricing.Quote.md#prospicio.pricing.Quote.limit) xs [attachment](reinsurance.Layer.md#prospicio.reinsurance.Layer.attachment), |
| [layer_variance()](#layer_variance) | Variance of the loss to the layer [limit](pricing.Quote.md#prospicio.pricing.Quote.limit) xs [attachment](reinsurance.Layer.md#prospicio.reinsurance.Layer.attachment). |
| [lev()](#lev) | Limited expected value `E[min(X, limit)]`. |
| [mean()](#mean) | Mean of the distribution (`inf` if it does not exist). |
| [quantile()](#quantile) | Quantile: the smallest [x](distributions.Ogive.md#prospicio.distributions.Ogive.x) with `P(X <= x) >= p`. |
| [sample()](#sample) | [n](pricing.TrendFit.md#prospicio.pricing.TrendFit.n) draws from stream `stream` of the generator keyed by |
| [std()](#std) | Standard deviation of the distribution. |
| [stop_loss()](#stop_loss) | Expected excess over a retention, `E[max(X - retention, 0)]`. |
| [survival()](#survival) | Survival function `P(X > x)`, accurate far into the tail. |
| [tvar()](#tvar) | Tail value at risk at [p](models.Elpd.md#prospicio.models.Elpd.p) in `[0, 1)`, the mean of the worst |
| [var()](#var) | Value at risk, the lower quantile at [p](models.Elpd.md#prospicio.models.Elpd.p): the same as [quantile](risk.Gpd.md#prospicio.risk.Gpd.quantile). |
| [variance()](#variance) | Variance of the distribution (`inf` if it does not exist). |

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


#### cdf()


Distribution function `P(X <= x)`.


Usage

``` python
cdf(x)
```


##### Parameters


`x: float`  


##### Returns


`float`  


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


#### layer()


Expected loss to the layer [limit](pricing.Quote.md#prospicio.pricing.Quote.limit) xs [attachment](reinsurance.Layer.md#prospicio.reinsurance.Layer.attachment).


Usage

``` python
layer(limit, attachment)
```


##### Parameters


`limit: float`  
`inf` for an unlimited layer.

`attachment: float`  


##### Returns


`float`  


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


#### layer_second_moment()


Second moment of the loss to the layer [limit](pricing.Quote.md#prospicio.pricing.Quote.limit) xs


Usage

``` python
layer_second_moment(limit, attachment)
```


[attachment](reinsurance.Layer.md#prospicio.reinsurance.Layer.attachment).


##### Parameters


`limit: float`  

`attachment: float`  


##### Returns


`float`  


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


#### layer_third_moment()


Third moment of the loss to the layer [limit](pricing.Quote.md#prospicio.pricing.Quote.limit) xs [attachment](reinsurance.Layer.md#prospicio.reinsurance.Layer.attachment),


Usage

``` python
layer_third_moment(limit, attachment)
```


`E[min(max(X - a, 0), l)^3]`, by quadrature of the survival function (relative accuracy about 1e-10); `limit = inf` for the unlimited layer, `attachment = 0` for the limited third moment.


##### Parameters


`limit: float`  

`attachment: float`  


##### Returns


`float`  


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


#### layer_variance()


Variance of the loss to the layer [limit](pricing.Quote.md#prospicio.pricing.Quote.limit) xs [attachment](reinsurance.Layer.md#prospicio.reinsurance.Layer.attachment).


Usage

``` python
layer_variance(limit, attachment)
```


##### Parameters


`limit: float`  

`attachment: float`  


##### Returns


`float`  


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


#### lev()


Limited expected value `E[min(X, limit)]`.


Usage

``` python
lev(limit)
```


##### Parameters


`limit: float`  


##### Returns


`float`  


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


#### mean()


Mean of the distribution (`inf` if it does not exist).


Usage

``` python
mean()
```


##### Returns


`float`  


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


#### quantile()


Quantile: the smallest [x](distributions.Ogive.md#prospicio.distributions.Ogive.x) with `P(X <= x) >= p`.


Usage

``` python
quantile(p)
```


##### Parameters


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


##### Returns


`float`  


##### Raises


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


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


#### sample()


[n](pricing.TrendFit.md#prospicio.pricing.TrendFit.n) draws 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 float`  


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


#### std()


Standard deviation of the distribution.


Usage

``` python
std()
```


##### Returns


`float`  


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


#### stop_loss()


Expected excess over a retention, `E[max(X - retention, 0)]`.


Usage

``` python
stop_loss(retention)
```


##### Parameters


`retention: float`  


##### Returns


`float`  


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


#### survival()


Survival function `P(X > x)`, accurate far into the tail.


Usage

``` python
survival(x)
```


##### Parameters


`x: float`  


##### Returns


`float`  


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


#### tvar()


Tail value at risk at [p](models.Elpd.md#prospicio.models.Elpd.p) in `[0, 1)`, the mean of the worst


Usage

``` python
tvar(p)
```


`1 - p`: `VaR(p) + E[(X - VaR(p))+] / (1 - p)`; `inf` where the mean is.


##### Parameters


`p: float`  


##### Returns


`float`  


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


#### var()


Value at risk, the lower quantile at [p](models.Elpd.md#prospicio.models.Elpd.p): the same as [quantile](risk.Gpd.md#prospicio.risk.Gpd.quantile).


Usage

``` python
var(p)
```


##### Parameters


`p: float`  


##### Returns


`float`  


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


#### variance()


Variance of the distribution (`inf` if it does not exist).


Usage

``` python
variance()
```


##### Returns


`float`
