## distributions.Ogive


An ogive: the piecewise linear distribution function through tabulated


Usage

``` python
distributions.Ogive()
```


points `(x, F(x))`, the usual reading of grouped loss data (losses uniform within each band), as in *Pricing Insurance Risk*, Exercise 50.

Its limited moments are exact, band by band. Build one from grouped counts with [Ogive.from_counts()](distributions.Ogive.md#prospicio.distributions.Ogive.from_counts).


## Parameters


`x: list of float`  
At least two band boundaries, finite, non-negative and strictly increasing.

`cdf: list of float`  
`F` at each boundary, non-decreasing from 0 to 1.


## Raises


`ValueError`  
If the table breaks any of these.


## Examples

``` python
>>> from prospicio.distributions import Ogive
>>> o = Ogive.from_counts([0, 1000, 5000, 10000], [40, 50, 10])
>>> o.cdf(3000.0), round(o.quantile(0.95), 6), round(o.tvar(0.95), 6)
```

(0.65, 7500.0, 8750.0)


## Attributes

| Name | Description |
|----|----|
| [cdf_values](#cdf_values) | `F` at the boundaries. |
| [x](#x) | The band boundaries. |

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


#### cdf_values


`F` at the boundaries.


`cdf_values: list[float]`


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


#### x


The band boundaries.


`x: list[float]`


## Methods

| Name | Description |
|----|----|
| [cdf()](#cdf) | `P(X <= x)`, linear between the boundaries. |
| [from_counts()](#from_counts) | The ogive of grouped data: `counts[k]` losses (or any weights) |
| [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_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) | The mean. |
| [pdf()](#pdf) | The density, constant on each band and 0 outside. |
| [quantile()](#quantile) | The lower quantile, the smallest [x](distributions.Ogive.md#prospicio.distributions.Ogive.x) with `F(x) >= p`. |
| [sample()](#sample) | [n](pricing.TrendFit.md#prospicio.pricing.TrendFit.n) draws from stream `stream` of the generator keyed by [seed](aggregate.EventSet.md#prospicio.aggregate.EventSet.seed). |
| [std_dev()](#std_dev) | The standard deviation. |
| [survival()](#survival) | `P(X > x)`. |
| [tvar()](#tvar) | Tail value at risk at [p](models.Elpd.md#prospicio.models.Elpd.p), the mean of the worst `1 - p`. |
| [variance()](#variance) | The variance. |

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


#### cdf()


`P(X <= x)`, linear between the boundaries.


Usage

``` python
cdf(x)
```


##### Parameters


`x: float`  


##### Returns


`float`  


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


#### from_counts()


The ogive of grouped data: `counts[k]` losses (or any weights)


Usage

``` python
from_counts(bounds, counts)
```


between `bounds[k]` and `bounds[k + 1]`, spread uniformly.


##### Parameters


`bounds: list of float`  
One more than the counts.

`counts: list of float`  
Non-negative, with a positive total.


##### Returns


`Ogive`  


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


#### 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`  

`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()


The mean.


Usage

``` python
mean()
```


##### Returns


`float`  


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


#### pdf()


The density, constant on each band and 0 outside.


Usage

``` python
pdf(x)
```


##### Parameters


`x: float`  


##### Returns


`float`  


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


#### quantile()


The lower quantile, the smallest [x](distributions.Ogive.md#prospicio.distributions.Ogive.x) with `F(x) >= p`.


Usage

``` python
quantile(p)
```


##### Parameters


`p: float`  
In `[0, 1]`.


##### Returns


`float`  


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


#### sample()


[n](pricing.TrendFit.md#prospicio.pricing.TrendFit.n) draws from stream `stream` of the generator keyed by [seed](aggregate.EventSet.md#prospicio.aggregate.EventSet.seed).


Usage

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


##### Parameters


`n: int`  

`seed: int`  

`stream: int = ``0`  


##### Returns


`list of float`  


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


#### std_dev()


The standard deviation.


Usage

``` python
std_dev()
```


##### Returns


`float`  


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


#### survival()


`P(X > x)`.


Usage

``` python
survival(x)
```


##### Parameters


`x: float`  


##### Returns


`float`  


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


#### tvar()


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


Usage

``` python
tvar(p)
```


##### Parameters


`p: float`  
In `[0, 1)`.


##### Returns


`float`  


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


#### variance()


The variance.


Usage

``` python
variance()
```


##### Returns


`float`
