## pricing.InsuranceCharge


The insurance charge and savings of an aggregate loss distribution, at


Usage

``` python
pricing.InsuranceCharge()
```


any entry ratio: a Table M without the rows.

For aggregate losses `A` with mean `E` and an entry ratio [r](distributions.NegativeBinomial.md#prospicio.distributions.NegativeBinomial.r), the charge is `phi(r) = E[max(A / E - r, 0)]` and the savings `psi(r) = E[max(r - A / E, 0)]`, with `phi(r) - psi(r) = 1 - r`.

Build one with [InsuranceCharge.from_grid](pricing.InsuranceCharge.md#prospicio.pricing.InsuranceCharge.from_grid) (an aggregate on a grid, from [fft](aggregate.fft.md#prospicio.aggregate.fft) or [panjer](aggregate.panjer.md#prospicio.aggregate.panjer)) or [InsuranceCharge.from_sample](pricing.InsuranceCharge.md#prospicio.pricing.InsuranceCharge.from_sample) (simulated or observed totals). With a per-occurrence limit, build it from the limited aggregate (the limited Table M) and call [table_l](pricing.InsuranceCharge.md#prospicio.pricing.InsuranceCharge.table_l) for a Table L.


## Examples

``` python
>>> from prospicio.pricing import InsuranceCharge
>>> table = InsuranceCharge.from_sample([0.0, 50.0, 100.0, 250.0])
>>> table.expected
```

100.0

``` python
>>> table.charge(1.0), table.savings(1.0)
```

(0.375, 0.375)


## Attributes

| Name | Description |
|----|----|
| [expected](#expected) | What the entry ratios multiply: the expected aggregate loss, and |
| [loss_elimination](#loss_elimination) | A Table L's share of expected losses removed by the limit; 0 for |

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


#### expected


What the entry ratios multiply: the expected aggregate loss, and


`expected: float`


for a Table L the expected loss without the limit.


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


#### loss_elimination


A Table L's share of expected losses removed by the limit; 0 for


`loss_elimination: float`


any other table.


## Methods

| Name | Description |
|----|----|
| [charge()](#charge) | The insurance charge `phi(r)`. |
| [from_grid()](#from_grid) | The table of an aggregate loss distribution on a grid. |
| [from_sample()](#from_sample) | The table of a sample of aggregate losses, each equally likely: |
| [savings()](#savings) | The insurance savings `psi(r) = phi(r) + r - 1`. |
| [table()](#table) | The table at the given entry ratios. |
| [table_l()](#table_l) | This table of a limited aggregate as a Table L: entry ratios become |

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


#### charge()


The insurance charge `phi(r)`.


Usage

``` python
charge(entry_ratio)
```


##### Parameters


`entry_ratio: float`  


##### Returns


`float`  


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


#### from_grid()


The table of an aggregate loss distribution on a grid.


Usage

``` python
from_grid(aggregate)
```


##### Parameters


`aggregate: Grid`  
The aggregate losses, as [fft](aggregate.fft.md#prospicio.aggregate.fft) or [panjer](aggregate.panjer.md#prospicio.aggregate.panjer) return them.


##### Returns


`InsuranceCharge`  


##### Raises


`ValueError`  
If the grid's mean is not positive.


##### Examples

``` python
>>> from prospicio.distributions import Grid
>>> from prospicio.pricing import InsuranceCharge
>>> agg = Grid(50.0, [0.25, 0.25, 0.25, 0.0, 0.0, 0.25])
>>> InsuranceCharge.from_grid(agg).charge(0.5)
```

0.625

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


#### from_sample()


The table of a sample of aggregate losses, each equally likely:


Usage

``` python
from_sample(losses)
```


simulated years, or the experience of a group of similar risks.


##### Parameters


`losses: list of float`  
The totals, in any order.


##### Returns


`InsuranceCharge`  


##### Raises


`ValueError`  
If the sample is empty, holds a negative or non-finite loss, or has mean zero.


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


#### savings()


The insurance savings `psi(r) = phi(r) + r - 1`.


Usage

``` python
savings(entry_ratio)
```


##### Parameters


`entry_ratio: float`  


##### Returns


`float`  


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


#### table()


The table at the given entry ratios.


Usage

``` python
table(entry_ratios)
```


##### Parameters


`entry_ratios: list of float`  


##### Returns


`dict`  
Columns `entry_ratio`, [charge](pricing.InsuranceCharge.md#prospicio.pricing.InsuranceCharge.charge) and [savings](pricing.InsuranceCharge.md#prospicio.pricing.InsuranceCharge.savings), one value per entry ratio, in their order.


##### Examples

``` python
>>> from prospicio.pricing import InsuranceCharge
>>> t = InsuranceCharge.from_sample([0.0, 50.0, 100.0, 250.0]).table([0.0, 0.5, 1.0])
>>> t["charge"], t["savings"]
```

(\[1.0, 0.625, 0.375\], \[0.0, 0.125, 0.375\])

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


#### table_l()


This table of a limited aggregate as a Table L: entry ratios become


Usage

``` python
table_l(unlimited_expected)
```


multiples of the unlimited expected loss, and the charge takes on the share of losses the per-occurrence limit removes.


##### Parameters


`unlimited_expected: float`  
The expected aggregate loss without the limit.


##### Returns


`InsuranceCharge`  


##### Raises


`ValueError`  
If `unlimited_expected` is below the limited mean or not finite, or the table is already a Table L.


##### Examples

``` python
>>> from prospicio.pricing import InsuranceCharge
>>> limited = InsuranceCharge.from_sample([110.0, 100.0, 0.0, 200.0])
>>> table = limited.table_l(132.5)
>>> round(table.loss_elimination, 6)
```

0.226415

``` python
>>> table.charge(0.0)
```

1.0
