# Aggregate distributions: FFT, Panjer, simulation or moments

Use this guide to compute the distribution of the total loss of a year (the **aggregate loss**), or of what one reinsurance contract pays out of it. prospicio has four engines: closed-form **moments**, **FFT** (fast Fourier transform on a grid), **Panjer**'s recursion and **Monte Carlo simulation**. Each fails in its own way. The guide says which engine to use, how to size and check it, and the exact calls. It is for an actuary who knows frequency and severity from primary pricing and is new to reinsurance pricing. Money is in millions. CI runs the code and checks every printed number.


# The decision table

| Situation | Method | prospicio call | Why |
|----|----|----|----|
| Mean, standard deviation and skewness of the year, or a sanity check | Moments | [compound_moments](../reference/aggregate.compound_moments.md#prospicio.aggregate.compound_moments) | Closed form, no grid, no sampling error. Its fitted distributions are rough in the tail |
| Quantiles, stop-loss prices or any tail number for one book | FFT, grid sized for you | [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) | Exact for the discretized problem, error reported |
| The same, with a bucket you must use (a policy limit, a market convention) | FFT on your grid | [Grid.local_moment](../reference/distributions.Grid.md#prospicio.distributions.Grid.local_moment) then [fft](../reference/aggregate.fft.md#prospicio.aggregate.fft) | You control the step. [local_moment](../reference/distributions.Grid.md#prospicio.distributions.Grid.local_moment) keeps the mean |
| An independent exact check of an FFT result | Panjer | [panjer](../reference/aggregate.panjer.md#prospicio.aggregate.panjer) | Same answer by a different algorithm. No aliasing |
| A large claim count (a Poisson mean of several hundred or more) | FFT | [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) | Panjer fails once the probability of a zero year underflows: a Poisson mean of 745 runs, 800 does not (section 4) |
| Claims that cluster (contagion, or an uncertain claim rate) | FFT with a mixed Poisson count | `fft_auto(Count.mixed_poisson(...), sev)` | A more variable count gives a fatter annual tail. Panjer refuses it (section 3.6) |
| A policy limit or deductible on each claim | FFT on a mapped grid | [Grid.local_moment](../reference/distributions.Grid.md#prospicio.distributions.Grid.local_moment), [Grid.map](../reference/distributions.Grid.md#prospicio.distributions.Grid.map), then [fft](../reference/aggregate.fft.md#prospicio.aggregate.fft) | [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) sizes for the severity it gets (section 3.7) |
| A count that is not Poisson, negative binomial or binomial | FFT | [fft](../reference/aggregate.fft.md#prospicio.aggregate.fft) with a [Count](../reference/distributions.Count.md#prospicio.distributions.Count) | Panjer needs the count families of the recursion |
| Heavy tail with infinite variance | FFT, grid sized by one big claim | [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) | Moments are undefined. The sizing does not need them |
| What an excess layer, quota share, stop loss, reinstatements or a corridor pay | FFT on the tower | [Tower.on_grid](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.on_grid) | Exact, no sampling error |
| A quota share or stop loss (with its commissions) on an annual loss already on a grid, such as a loss ratio times premium | The tower on the annual grid | [Tower.on_annual_grid](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.on_annual_grid) | The total of each year is one loss. No claim count is needed, and the expected commissions are exact |
| Reinstatement premium pro rata as to time, a surplus treaty, annual terms that inure to a later layer | Simulation | [Tower.apply](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.apply) on an [EventSet](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet) | They need event order, dates or sums insured. A compound grid has none |
| Several layers or lines together (joint distribution, dependence) | Simulation | [Tower.apply](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.apply), [PredictiveDistribution](../reference/distributions.PredictiveDistribution.md#prospicio.distributions.PredictiveDistribution) | A grid is one marginal distribution |
| The event loss table of a catastrophe model | Simulation | `events, rows = EventLossTable(...).simulate(n_years, seed)` | Returns the years and the row in the table of each loss. Draws the loss of each event from its secondary uncertainty. Exact OEP and PML from [EventLossTable.oep](../reference/aggregate.EventLossTable.md#prospicio.aggregate.EventLossTable.oep) and [EventLossTable.occurrence_pml](../reference/aggregate.EventLossTable.md#prospicio.aggregate.EventLossTable.occurrence_pml) |
| Your own simulated years (a year loss table), a non-cat set beside a cat set, an hours clause | Simulation | [EventSet.from_long](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.from_long) or [EventSet.from_years](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.from_years), [EventSet.merge](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.merge), `EventSet.grouped(window_hours)` | The events are the model. [merge](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.merge) needs the same number of years in both sets. [grouped](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.grouped) needs loss times (fractions of a year) and drops sums insured |
| The largest single loss of the year (occurrence PML) | Closed form | [occurrence_pml](../reference/aggregate.occurrence_pml.md#prospicio.aggregate.occurrence_pml), [occurrence_exceedance](../reference/aggregate.occurrence_exceedance.md#prospicio.aggregate.occurrence_exceedance) | For per-occurrence covers the annual total is the wrong curve |
| How often a layer is hit, its loss on line, its count and severity moments | Closed form | [occurrence_layer_statistics](../reference/reinsurance.occurrence_layer_statistics.md#prospicio.reinsurance.occurrence_layer_statistics) | One call |

One rule covers most cases: **use FFT unless a contract term forces simulation, and read the report either way.**


# 1. The running book

The running book is synthetic: six claims a year on average (Poisson) and lognormal claim sizes with mean 1 and coefficient of variation 2. We want the annual distribution and the price of a per-occurrence layer of 5 xs 5 (a limit of 5 above an attachment of 5).


``` python
from prospicio.aggregate import (
    compound_moments, fft, fft_auto, occurrence_exceedance, occurrence_pml,
    panjer, recommend_grid, round_bucket, simulate_events,
)
from prospicio.distributions import Count, Grid, Lognormal, Pareto, Poisson
from prospicio.pricing import CollectiveModel, Mbbefd, RiskProfile
from prospicio.reinsurance import Layer, Tower, occurrence_layer_statistics

freq = Poisson(6.0)
sev = Lognormal.from_mean_cv(1.0, 2.0)

annual, report, size = fft_auto(freq, sev, 12)
print(f"step {size.step}, points {size.points}, sized by {size.method}")
print(f"mean {annual.mean():.4f}, sd {annual.variance() ** 0.5:.4f}")
print(f"99%: {annual.quantile(0.99):.2f}, 99.5%: {annual.quantile(0.995):.2f}")
```


    step 0.0625, points 4096, sized by single_big_jump
    mean 5.9999, sd 5.4683
    99%: 25.81, 99.5%: 31.56


The `12` caps the grid at `2**12` points (default `2**16`, a finer step). The 99% value is the annual loss exceeded with probability 1%.

For a Poisson count the expected annual loss to a layer is the expected claim count times the layer mean of the severity. [CollectiveModel](../reference/pricing.CollectiveModel.md#prospicio.pricing.CollectiveModel) gives this closed form, and later sections compare every engine with it.


``` python
model = CollectiveModel(freq, sev)
exact = model.layer_mean(5.0, 5.0)  # limit, then attachment
print(f"expected annual loss to 5 xs 5: {exact:.5f}")
print(f"standard deviation: {model.layer_std(5.0, 5.0):.4f}")
```


    expected annual loss to 5 xs 5: 0.43812
    standard deviation: 1.3018


# 2. Moments: when closed form is enough

[compound_moments](../reference/aggregate.compound_moments.md#prospicio.aggregate.compound_moments) gives the mean, variance, skewness and third cumulant of the year in closed form, with no grid and no sampling error. `.approximate(kind)` fits a distribution to them.


``` python
m = compound_moments(freq, sev)
print(f"mean {m.mean:.3f}, cv {m.cv:.4f}, skew {m.skew:.4f}")
```


    mean 6.000, cv 0.9129, skew 4.5644


``` python
import pandas as pd
from great_tables import GT

rows = []
for kind in ["normal", "gamma", "lognormal", "shifted_gamma", "shifted_lognormal"]:
    fit = m.approximate(kind)
    rows.append({"fit": kind, "q99": fit.quantile(0.99), "q995": fit.quantile(0.995),
                 "err99": fit.quantile(0.99) / annual.quantile(0.99) - 1,
                 "err995": fit.quantile(0.995) / annual.quantile(0.995) - 1})
rows.append({"fit": "FFT", "q99": annual.quantile(0.99), "q995": annual.quantile(0.995),
             "err99": 0.0, "err995": 0.0})
(GT(pd.DataFrame(rows), rowname_col="fit")
 .tab_header("Moment fits against the FFT", "Annual loss at two quantiles, running book")
 .tab_spanner("annual loss (money units)", ["q99", "q995"])
 .tab_spanner("error against the FFT", ["err99", "err995"])
 .cols_label(q99="99%", q995="99.5%", err99="99%", err995="99.5%")
 .fmt_number(["q99", "q995"], decimals=2)
 .fmt_percent(["err99", "err995"], decimals=1))
```


<style>
#qrmcnenldl table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#qrmcnenldl thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#qrmcnenldl p { margin: 0; padding: 0; }
 #qrmcnenldl .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #qrmcnenldl .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #qrmcnenldl .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #qrmcnenldl .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #qrmcnenldl .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #qrmcnenldl .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #qrmcnenldl .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #qrmcnenldl .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #qrmcnenldl .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #qrmcnenldl .gt_column_spanner_outer:first-child { padding-left: 0; }
 #qrmcnenldl .gt_column_spanner_outer:last-child { padding-right: 0; }
 #qrmcnenldl .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #qrmcnenldl .gt_spanner_row { border-bottom-style: hidden; }
 #qrmcnenldl .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #qrmcnenldl .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #qrmcnenldl .gt_from_md> :first-child { margin-top: 0; }
 #qrmcnenldl .gt_from_md> :last-child { margin-bottom: 0; }
 #qrmcnenldl .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #qrmcnenldl .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #qrmcnenldl .gt_indent_1 { text-indent: 5px; }
 #qrmcnenldl .gt_indent_2 { text-indent: calc(5px * 2); }
 #qrmcnenldl .gt_indent_3 { text-indent: calc(5px * 3); }
 #qrmcnenldl .gt_indent_4 { text-indent: calc(5px * 4); }
 #qrmcnenldl .gt_indent_5 { text-indent: calc(5px * 5); }
 #qrmcnenldl .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #qrmcnenldl .gt_row_group_first td { border-top-width: 2px; }
 #qrmcnenldl .gt_row_group_first th { border-top-width: 2px; }
 #qrmcnenldl .gt_striped { color: #333333; background-color: #F4F4F4; }
 #qrmcnenldl .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #qrmcnenldl .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #qrmcnenldl .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #qrmcnenldl .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #qrmcnenldl .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #qrmcnenldl .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #qrmcnenldl .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #qrmcnenldl .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #qrmcnenldl .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #qrmcnenldl .gt_left { text-align: left; }
 #qrmcnenldl .gt_center { text-align: center; }
 #qrmcnenldl .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #qrmcnenldl .gt_font_normal { font-weight: normal; }
 #qrmcnenldl .gt_font_bold { font-weight: bold; }
 #qrmcnenldl .gt_font_italic { font-style: italic; }
 #qrmcnenldl .gt_super { font-size: 65%; }
 #qrmcnenldl .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #qrmcnenldl .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #qrmcnenldl .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #qrmcnenldl .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #qrmcnenldl .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #qrmcnenldl .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="5" id="title" class="gt_heading gt_title gt_font_normal">Moment fits against the FFT</th>
</tr>
<tr class="gt_heading">
<th colspan="5" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Annual loss at two quantiles, running book</th>
</tr>
<tr class="gt_col_headings gt_spanner_row">
<th rowspan="2" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th colspan="2" id="annual-loss-money-units" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">annual loss (money units)</th>
<th colspan="2" id="error-against-the-FFT" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">error against the FFT</th>
</tr>
<tr class="gt_col_headings">
<th id="q99" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99%</th>
<th id="q995" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99.5%</th>
<th id="err99" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99%</th>
<th id="err995" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99.5%</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">normal</th>
<td class="gt_row gt_right" headers="stub-1 annual-loss-money-units q99">18.74</td>
<td class="gt_row gt_right" headers="stub-1 annual-loss-money-units q995">20.11</td>
<td class="gt_row gt_right" headers="stub-1 error-against-the-FFT err99">−27.4%</td>
<td class="gt_row gt_right" headers="stub-1 error-against-the-FFT err995">−36.3%</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">gamma</th>
<td class="gt_row gt_right" headers="stub-2 annual-loss-money-units q99">25.24</td>
<td class="gt_row gt_right" headers="stub-2 annual-loss-money-units q995">28.82</td>
<td class="gt_row gt_right" headers="stub-2 error-against-the-FFT err99">−2.2%</td>
<td class="gt_row gt_right" headers="stub-2 error-against-the-FFT err995">−8.7%</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">lognormal</th>
<td class="gt_row gt_right" headers="stub-3 annual-loss-money-units q99">27.11</td>
<td class="gt_row gt_right" headers="stub-3 annual-loss-money-units q995">32.92</td>
<td class="gt_row gt_right" headers="stub-3 error-against-the-FFT err99">5.0%</td>
<td class="gt_row gt_right" headers="stub-3 error-against-the-FFT err995">4.3%</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">shifted_gamma</th>
<td class="gt_row gt_right" headers="stub-4 annual-loss-money-units q99">30.63</td>
<td class="gt_row gt_right" headers="stub-4 annual-loss-money-units q995">37.50</td>
<td class="gt_row gt_right" headers="stub-4 error-against-the-FFT err99">18.6%</td>
<td class="gt_row gt_right" headers="stub-4 error-against-the-FFT err995">18.8%</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">shifted_lognormal</th>
<td class="gt_row gt_right" headers="stub-5 annual-loss-money-units q99">27.59</td>
<td class="gt_row gt_right" headers="stub-5 annual-loss-money-units q995">34.16</td>
<td class="gt_row gt_right" headers="stub-5 error-against-the-FFT err99">6.9%</td>
<td class="gt_row gt_right" headers="stub-5 error-against-the-FFT err995">8.2%</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">FFT</th>
<td class="gt_row gt_right" headers="stub-6 annual-loss-money-units q99">25.81</td>
<td class="gt_row gt_right" headers="stub-6 annual-loss-money-units q995">31.56</td>
<td class="gt_row gt_right" headers="stub-6 error-against-the-FFT err99">0.0%</td>
<td class="gt_row gt_right" headers="stub-6 error-against-the-FFT err995">0.0%</td>
</tr>
</tbody>
</table>


**Use moments** for the mean and spread of a year: a quick load, a check on a grid or a simulation, or the input to a rule that needs only a standard deviation. **Do not use the fits for capital or layer prices.** A fit matches three numbers and says nothing else about the shape, and no family is right at both quantiles.

**Data needed**: any count, and a severity with a finite third moment (a heavy tail has none, section 3.5). The shifted fits also need positive skewness.


# 3. FFT: the default engine

An FFT turns the convolution of `N` severities into a product in the Fourier domain, so the whole distribution costs about `n log n` for an [n](../reference/pricing.TrendFit.md#prospicio.pricing.TrendFit.n)-point grid. It works for any count with a probability generating function and for large counts. It is **exact for the discretized problem**; the approximations are the discretization, the finite grid and aliasing.


## 3.1 Let the library size the grid

[recommend_grid](../reference/aggregate.recommend_grid.md#prospicio.aggregate.recommend_grid) sizes the grid as the Python package [aggregate](../reference/aggregate.Clash.md#prospicio.aggregate.Clash.aggregate) does, and [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) sizes it so, then runs the FFT. The step is on a ladder of values ([round_bucket](../reference/aggregate.round_bucket.md#prospicio.aggregate.round_bucket)).


``` python
print(size)
print(f"extent {size.extent:.1f}, grid reaches {size.step * size.points:.1f}")
print([round_bucket(x) for x in (0.3, 0.7, 3.4, 6.0, 30.0)])
```


    GridSize(step=0.0625, points=4096, method="single_big_jump", tail_estimate=1.6733116333700584e-6)
    extent 167.9, grid reaches 256.0
    [0.5, 1.0, 4.0, 8.0, 40.0]


- [extent](../reference/aggregate.GridSize.md#prospicio.aggregate.GridSize.extent) is how far the grid must reach. [step](../reference/esg.Scenarios.md#prospicio.esg.Scenarios.step) is [extent](../reference/aggregate.GridSize.md#prospicio.aggregate.GridSize.extent) over the points, rounded up the ladder.
- [method](../reference/risk.Allocation.md#prospicio.risk.Allocation.method) says what set the extent: `"moments"` (a lognormal or gamma fitted to the mean and variance of the year) or `"single_big_jump"` (one big claim on top of a typical year, which governs heavy tails).
- [tail_estimate](../reference/aggregate.GridSize.md#prospicio.aggregate.GridSize.tail_estimate) is roughly the probability beyond the grid from one claim. If it is not tiny, increase [log2](../reference/aggregate.GridAudit.md#prospicio.aggregate.GridAudit.log2).


## 3.2 Read the report every time

[fft](../reference/aggregate.fft.md#prospicio.aggregate.fft) and [panjer](../reference/aggregate.panjer.md#prospicio.aggregate.panjer) also return a [CompoundReport](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport). Read it in this order:

| Field | Meaning | Act when |
|----|----|----|
| [aliasing_error](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.aliasing_error) | Largest change in any probability when the FFT buffer doubles | Above about `1e-9` (a rule of thumb, not a bound): the grid is unreliable, [tail_mass](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.tail_mass) included. Lengthen the grid |
| [tail_mass](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.tail_mass) | Probability beyond the last point, put on that point | Not small beside the tail you price (a 99.5% quantile needs it well under 0.5%) |
| [mean_error()](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.mean_error) | Grid mean minus `E[N] E[X]` on the severity grid | Not tiny: lost tail or aliasing |
| [points](../reference/aggregate.GridSize.md#prospicio.aggregate.GridSize.points) | Length of the result | Shorter than you meant |

A grid that is too short shows at once (same book and step):


``` python
def tiny(x):
    """Print a residual, or '<1e-10' when it is rounding noise that differs by platform."""
    return f"{x:.1e}" if x >= 1e-10 else "<1e-10"


rows = []
for n in (128, 256, 512, 1024, 4096):
    g, disc = Grid.local_moment(sev, 0.0625, n)
    a, r = fft(freq, g, n)
    rows.append({"points": f"{n:,}", "tail_mass": f"{r.tail_mass:.1e}", "aliasing": tiny(r.aliasing_error),
                 "mean_error": f"{r.mean_error():+.1e}", "grid_mean": a.mean()})
(GT(pd.DataFrame(rows), rowname_col="points")
 .tab_header("The report of a growing grid", "Same book and step 0.0625; the exact mean is 6")
 .cols_label(tail_mass="tail mass", aliasing="aliasing", mean_error="mean error", grid_mean="grid mean")
 .fmt_number("grid_mean", decimals=3))
```


<style>
#czdbwxhlxw table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#czdbwxhlxw thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#czdbwxhlxw p { margin: 0; padding: 0; }
 #czdbwxhlxw .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #czdbwxhlxw .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #czdbwxhlxw .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #czdbwxhlxw .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #czdbwxhlxw .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #czdbwxhlxw .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #czdbwxhlxw .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #czdbwxhlxw .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #czdbwxhlxw .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #czdbwxhlxw .gt_column_spanner_outer:first-child { padding-left: 0; }
 #czdbwxhlxw .gt_column_spanner_outer:last-child { padding-right: 0; }
 #czdbwxhlxw .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #czdbwxhlxw .gt_spanner_row { border-bottom-style: hidden; }
 #czdbwxhlxw .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #czdbwxhlxw .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #czdbwxhlxw .gt_from_md> :first-child { margin-top: 0; }
 #czdbwxhlxw .gt_from_md> :last-child { margin-bottom: 0; }
 #czdbwxhlxw .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #czdbwxhlxw .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #czdbwxhlxw .gt_indent_1 { text-indent: 5px; }
 #czdbwxhlxw .gt_indent_2 { text-indent: calc(5px * 2); }
 #czdbwxhlxw .gt_indent_3 { text-indent: calc(5px * 3); }
 #czdbwxhlxw .gt_indent_4 { text-indent: calc(5px * 4); }
 #czdbwxhlxw .gt_indent_5 { text-indent: calc(5px * 5); }
 #czdbwxhlxw .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #czdbwxhlxw .gt_row_group_first td { border-top-width: 2px; }
 #czdbwxhlxw .gt_row_group_first th { border-top-width: 2px; }
 #czdbwxhlxw .gt_striped { color: #333333; background-color: #F4F4F4; }
 #czdbwxhlxw .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #czdbwxhlxw .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #czdbwxhlxw .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #czdbwxhlxw .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #czdbwxhlxw .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #czdbwxhlxw .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #czdbwxhlxw .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #czdbwxhlxw .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #czdbwxhlxw .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #czdbwxhlxw .gt_left { text-align: left; }
 #czdbwxhlxw .gt_center { text-align: center; }
 #czdbwxhlxw .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #czdbwxhlxw .gt_font_normal { font-weight: normal; }
 #czdbwxhlxw .gt_font_bold { font-weight: bold; }
 #czdbwxhlxw .gt_font_italic { font-style: italic; }
 #czdbwxhlxw .gt_super { font-size: 65%; }
 #czdbwxhlxw .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #czdbwxhlxw .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #czdbwxhlxw .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #czdbwxhlxw .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #czdbwxhlxw .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #czdbwxhlxw .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="5" id="title" class="gt_heading gt_title gt_font_normal">The report of a growing grid</th>
</tr>
<tr class="gt_heading">
<th colspan="5" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Same book and step 0.0625; the exact mean is 6</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="tail_mass" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col">tail mass</th>
<th id="aliasing" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col">aliasing</th>
<th id="mean_error" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col">mean error</th>
<th id="grid_mean" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">grid mean</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">128</th>
<td class="gt_row gt_left" headers="stub-1 tail_mass">2.4e-01</td>
<td class="gt_row gt_left" headers="stub-1 aliasing">4.5e-04</td>
<td class="gt_row gt_left" headers="stub-1 mean_error">-8.4e-01</td>
<td class="gt_row gt_right" headers="stub-1 grid_mean">4.763</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">256</th>
<td class="gt_row gt_left" headers="stub-2 tail_mass">4.6e-02</td>
<td class="gt_row gt_left" headers="stub-2 aliasing">1.3e-05</td>
<td class="gt_row gt_left" headers="stub-2 mean_error">-1.9e-01</td>
<td class="gt_row gt_right" headers="stub-2 grid_mean">5.674</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">512</th>
<td class="gt_row gt_left" headers="stub-3 tail_mass">4.8e-03</td>
<td class="gt_row gt_left" headers="stub-3 aliasing">1.1e-07</td>
<td class="gt_row gt_left" headers="stub-3 mean_error">-2.5e-02</td>
<td class="gt_row gt_right" headers="stub-3 grid_mean">5.940</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">1,024</th>
<td class="gt_row gt_left" headers="stub-4 tail_mass">4.0e-04</td>
<td class="gt_row gt_left" headers="stub-4 aliasing">6.7e-10</td>
<td class="gt_row gt_left" headers="stub-4 mean_error">-2.3e-03</td>
<td class="gt_row gt_right" headers="stub-4 grid_mean">5.991</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">4,096</th>
<td class="gt_row gt_left" headers="stub-5 tail_mass">1.9e-06</td>
<td class="gt_row gt_left" headers="stub-5 aliasing"><1e-10</td>
<td class="gt_row gt_left" headers="stub-5 mean_error">-1.1e-05</td>
<td class="gt_row gt_right" headers="stub-5 grid_mean">6.000</td>
</tr>
</tbody>
</table>


Read [aliasing_error](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.aliasing_error) first: when it is large, wrapped mass sits inside the grid and [tail_mass](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.tail_mass) understates the truth. Passing it is not enough: the 1024-point row has aliasing 6.7e-10 and still 4.0e-4 of probability beyond the grid, too much for a 99.9% quantile. Both tests must pass.


## 3.3 Choosing the discretizer

When you choose the grid, three discretizers turn a continuous severity into grid probabilities. Each returns the grid and a [DiscretizationReport](../reference/distributions.DiscretizationReport.md#prospicio.distributions.DiscretizationReport).

| Call | What it does | Use for |
|----|----|----|
| `Grid.local_moment(sev, h, n)` | Splits the mass of each cell between its two neighbouring points, so it keeps the mean | Pricing. Means and layer means are right even at a coarse step |
| `Grid.rounding(sev, h, n)` | Moves each loss to the nearest point | Matching the reports of [aggregate](../reference/aggregate.Clash.md#prospicio.aggregate.Clash.aggregate). Fine at a small step. [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) uses it |
| `Grid.lower(sev, h, n)` | Moves the mass of each cell to its left end | A stochastic lower bound: it understates every loss, layer and quantile, so never use it for a price |

The same book at three steps (exact mean 6, exact 5 xs 5 value 0.43812):


``` python
tower = Tower([Layer("5x5", 5.0, 5.0)])
rows = []
for step, n in ((1.0, 128), (0.25, 512), (0.0625, 2048)):
    for name in ("rounding", "lower", "local_moment"):
        g, _ = getattr(Grid, name)(sev, step, n)
        grids = tower.on_grid(freq, g, n)
        rows.append({"step": f"{step}", "discretizer": name, "gross": grids.gross.mean(),
                     "layer": grids.ceded[0].mean(), "q99": grids.gross.quantile(0.99)})
(GT(pd.DataFrame(rows), rowname_col="step", groupname_col=None)
 .tab_header("Three discretizers at three steps", "Gross mean, 5 xs 5 layer mean and 99% quantile, money units")
 .cols_label(discretizer="discretizer", gross="gross mean", layer="5x5 layer", q99="99% quantile")
 .fmt_number(["gross", "layer"], decimals=4)
 .fmt_number("q99", decimals=2))
```


<style>
#brugzwkgnr table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#brugzwkgnr thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#brugzwkgnr p { margin: 0; padding: 0; }
 #brugzwkgnr .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #brugzwkgnr .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #brugzwkgnr .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #brugzwkgnr .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #brugzwkgnr .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #brugzwkgnr .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #brugzwkgnr .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #brugzwkgnr .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #brugzwkgnr .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #brugzwkgnr .gt_column_spanner_outer:first-child { padding-left: 0; }
 #brugzwkgnr .gt_column_spanner_outer:last-child { padding-right: 0; }
 #brugzwkgnr .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #brugzwkgnr .gt_spanner_row { border-bottom-style: hidden; }
 #brugzwkgnr .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #brugzwkgnr .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #brugzwkgnr .gt_from_md> :first-child { margin-top: 0; }
 #brugzwkgnr .gt_from_md> :last-child { margin-bottom: 0; }
 #brugzwkgnr .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #brugzwkgnr .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #brugzwkgnr .gt_indent_1 { text-indent: 5px; }
 #brugzwkgnr .gt_indent_2 { text-indent: calc(5px * 2); }
 #brugzwkgnr .gt_indent_3 { text-indent: calc(5px * 3); }
 #brugzwkgnr .gt_indent_4 { text-indent: calc(5px * 4); }
 #brugzwkgnr .gt_indent_5 { text-indent: calc(5px * 5); }
 #brugzwkgnr .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #brugzwkgnr .gt_row_group_first td { border-top-width: 2px; }
 #brugzwkgnr .gt_row_group_first th { border-top-width: 2px; }
 #brugzwkgnr .gt_striped { color: #333333; background-color: #F4F4F4; }
 #brugzwkgnr .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #brugzwkgnr .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #brugzwkgnr .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #brugzwkgnr .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #brugzwkgnr .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #brugzwkgnr .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #brugzwkgnr .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #brugzwkgnr .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #brugzwkgnr .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #brugzwkgnr .gt_left { text-align: left; }
 #brugzwkgnr .gt_center { text-align: center; }
 #brugzwkgnr .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #brugzwkgnr .gt_font_normal { font-weight: normal; }
 #brugzwkgnr .gt_font_bold { font-weight: bold; }
 #brugzwkgnr .gt_font_italic { font-style: italic; }
 #brugzwkgnr .gt_super { font-size: 65%; }
 #brugzwkgnr .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #brugzwkgnr .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #brugzwkgnr .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #brugzwkgnr .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #brugzwkgnr .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #brugzwkgnr .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="5" id="title" class="gt_heading gt_title gt_font_normal">Three discretizers at three steps</th>
</tr>
<tr class="gt_heading">
<th colspan="5" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Gross mean, 5 xs 5 layer mean and 99% quantile, money units</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="discretizer" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col">discretizer</th>
<th id="gross" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">gross mean</th>
<th id="layer" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">5x5 layer</th>
<th id="q99" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99% quantile</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">1.0</th>
<td class="gt_row gt_left" headers="stub-1 discretizer">rounding</td>
<td class="gt_row gt_right" headers="stub-1 gross">5.5738</td>
<td class="gt_row gt_right" headers="stub-1 layer">0.4360</td>
<td class="gt_row gt_right" headers="stub-1 q99">25.00</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">1.0</th>
<td class="gt_row gt_left" headers="stub-2 discretizer">lower</td>
<td class="gt_row gt_right" headers="stub-2 gross">3.7553</td>
<td class="gt_row gt_right" headers="stub-2 layer">0.3783</td>
<td class="gt_row gt_right" headers="stub-2 q99">23.00</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">1.0</th>
<td class="gt_row gt_left" headers="stub-3 discretizer">local_moment</td>
<td class="gt_row gt_right" headers="stub-3 gross">5.9987</td>
<td class="gt_row gt_right" headers="stub-3 layer">0.4381</td>
<td class="gt_row gt_right" headers="stub-3 q99">26.00</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">0.25</th>
<td class="gt_row gt_left" headers="stub-4 discretizer">rounding</td>
<td class="gt_row gt_right" headers="stub-4 gross">5.9775</td>
<td class="gt_row gt_right" headers="stub-4 layer">0.4380</td>
<td class="gt_row gt_right" headers="stub-4 q99">25.75</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">0.25</th>
<td class="gt_row gt_left" headers="stub-5 discretizer">lower</td>
<td class="gt_row gt_right" headers="stub-5 gross">5.2739</td>
<td class="gt_row gt_right" headers="stub-5 layer">0.4224</td>
<td class="gt_row gt_right" headers="stub-5 q99">24.75</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">0.25</th>
<td class="gt_row gt_left" headers="stub-6 discretizer">local_moment</td>
<td class="gt_row gt_right" headers="stub-6 gross">5.9987</td>
<td class="gt_row gt_right" headers="stub-6 layer">0.4381</td>
<td class="gt_row gt_right" headers="stub-6 q99">25.75</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">0.0625</th>
<td class="gt_row gt_left" headers="stub-7 discretizer">rounding</td>
<td class="gt_row gt_right" headers="stub-7 gross">5.9987</td>
<td class="gt_row gt_right" headers="stub-7 layer">0.4381</td>
<td class="gt_row gt_right" headers="stub-7 q99">25.81</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">0.0625</th>
<td class="gt_row gt_left" headers="stub-8 discretizer">lower</td>
<td class="gt_row gt_right" headers="stub-8 gross">5.8111</td>
<td class="gt_row gt_right" headers="stub-8 layer">0.4341</td>
<td class="gt_row gt_right" headers="stub-8 q99">25.56</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">0.0625</th>
<td class="gt_row gt_left" headers="stub-9 discretizer">local_moment</td>
<td class="gt_row gt_right" headers="stub-9 gross">5.9987</td>
<td class="gt_row gt_right" headers="stub-9 layer">0.4381</td>
<td class="gt_row gt_right" headers="stub-9 q99">25.81</td>
</tr>
</tbody>
</table>


[local_moment](../reference/distributions.Grid.md#prospicio.distributions.Grid.local_moment) has the mean right at every step; its shortfall below 6 is the tail beyond the last grid point. [lower](../reference/distributions.Grid.md#prospicio.distributions.Grid.lower) is a true lower bound and converges slowly. A grid quantile is a grid point, so quantiles move with the step.

[local_moment](../reference/distributions.Grid.md#prospicio.distributions.Grid.local_moment) keeps the mean, not the variance: splitting mass between two points adds spread. At a coarse step its quantiles and stop-loss premiums are a little high (26.00 at step 1.0 against 25.81 at the finest). Before you price a stop loss or quote a tail number, pass the halving check below.


## 3.4 Is the step fine enough? Halve it

The library reports only the discretization error of the mean. To check the step, halve it, double the points and see if your number moves.


``` python
rows, prev = [], None
for step, n in ((0.25, 512), (0.125, 1024), (0.0625, 2048), (0.03125, 4096)):
    g, _ = Grid.local_moment(sev, step, n)
    a, r = fft(freq, g, n)
    q = a.quantile(0.995)
    rows.append({"step": f"{step}", "q995": q, "change": None if prev is None else q - prev,
                 "stop_loss": a.stop_loss(30.0)})
    prev = q
(GT(pd.DataFrame(rows), rowname_col="step")
 .tab_header("Halving the step", "99.5% quantile and the stop-loss premium at 30, money units")
 .cols_label(q995="99.5%", change="change", stop_loss="stop loss at 30")
 .fmt_number("q995", decimals=4)
 .fmt_number("change", decimals=3, force_sign=True)
 .fmt_number("stop_loss", decimals=5)
 .sub_missing(missing_text=""))
```


<style>
#dgqdlbpeau table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#dgqdlbpeau thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#dgqdlbpeau p { margin: 0; padding: 0; }
 #dgqdlbpeau .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #dgqdlbpeau .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #dgqdlbpeau .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #dgqdlbpeau .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #dgqdlbpeau .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #dgqdlbpeau .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #dgqdlbpeau .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #dgqdlbpeau .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #dgqdlbpeau .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #dgqdlbpeau .gt_column_spanner_outer:first-child { padding-left: 0; }
 #dgqdlbpeau .gt_column_spanner_outer:last-child { padding-right: 0; }
 #dgqdlbpeau .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #dgqdlbpeau .gt_spanner_row { border-bottom-style: hidden; }
 #dgqdlbpeau .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #dgqdlbpeau .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #dgqdlbpeau .gt_from_md> :first-child { margin-top: 0; }
 #dgqdlbpeau .gt_from_md> :last-child { margin-bottom: 0; }
 #dgqdlbpeau .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #dgqdlbpeau .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #dgqdlbpeau .gt_indent_1 { text-indent: 5px; }
 #dgqdlbpeau .gt_indent_2 { text-indent: calc(5px * 2); }
 #dgqdlbpeau .gt_indent_3 { text-indent: calc(5px * 3); }
 #dgqdlbpeau .gt_indent_4 { text-indent: calc(5px * 4); }
 #dgqdlbpeau .gt_indent_5 { text-indent: calc(5px * 5); }
 #dgqdlbpeau .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #dgqdlbpeau .gt_row_group_first td { border-top-width: 2px; }
 #dgqdlbpeau .gt_row_group_first th { border-top-width: 2px; }
 #dgqdlbpeau .gt_striped { color: #333333; background-color: #F4F4F4; }
 #dgqdlbpeau .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #dgqdlbpeau .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #dgqdlbpeau .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #dgqdlbpeau .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #dgqdlbpeau .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #dgqdlbpeau .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #dgqdlbpeau .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #dgqdlbpeau .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #dgqdlbpeau .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #dgqdlbpeau .gt_left { text-align: left; }
 #dgqdlbpeau .gt_center { text-align: center; }
 #dgqdlbpeau .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #dgqdlbpeau .gt_font_normal { font-weight: normal; }
 #dgqdlbpeau .gt_font_bold { font-weight: bold; }
 #dgqdlbpeau .gt_font_italic { font-style: italic; }
 #dgqdlbpeau .gt_super { font-size: 65%; }
 #dgqdlbpeau .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #dgqdlbpeau .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #dgqdlbpeau .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #dgqdlbpeau .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #dgqdlbpeau .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #dgqdlbpeau .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="4" id="title" class="gt_heading gt_title gt_font_normal">Halving the step</th>
</tr>
<tr class="gt_heading">
<th colspan="4" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">99.5% quantile and the stop-loss premium at 30, money units</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="q995" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99.5%</th>
<th id="change" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">change</th>
<th id="stop_loss" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">stop loss at 30</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">0.25</th>
<td class="gt_row gt_right" headers="stub-1 q995">31.5000</td>
<td class="gt_row gt_right" headers="stub-1 change"></td>
<td class="gt_row gt_right" headers="stub-1 stop_loss">0.06879</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">0.125</th>
<td class="gt_row gt_right" headers="stub-2 q995">31.6250</td>
<td class="gt_row gt_right" headers="stub-2 change">+0.125</td>
<td class="gt_row gt_right" headers="stub-2 stop_loss">0.06877</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">0.0625</th>
<td class="gt_row gt_right" headers="stub-3 q995">31.5625</td>
<td class="gt_row gt_right" headers="stub-3 change">−0.062</td>
<td class="gt_row gt_right" headers="stub-3 stop_loss">0.06877</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">0.03125</th>
<td class="gt_row gt_right" headers="stub-4 q995">31.5938</td>
<td class="gt_row gt_right" headers="stub-4 change">+0.031</td>
<td class="gt_row gt_right" headers="stub-4 stop_loss">0.06877</td>
</tr>
</tbody>
</table>


A quantile moves one step at a time, so also judge a smooth number (a stop-loss premium, a layer mean). Here the quantile stays within one step, and the premium is stable to four digits from the first halving.


## 3.5 Heavy tails

A Pareto with [alpha](../reference/models.ElasticNet.md#prospicio.models.ElasticNet.alpha) 1.5 has a finite mean and an infinite variance. Moments refuse it, and one big claim sets the size of the grid:


``` python
heavy = Pareto(0.5, 1.5)  # threshold 0.5, alpha 1.5
try:
    compound_moments(freq, heavy)
except ValueError as e:
    print(e)
print(recommend_grid(freq, heavy, 12))
heavy_annual, heavy_report, _ = fft_auto(freq, heavy, 12)
print(f"tail mass {heavy_report.tail_mass:.1e}, aliasing {tiny(heavy_report.aliasing_error)}")
```


    invalid data: the severity's first three moments must be finite
    GridSize(step=1.0, points=4096, method="single_big_jump", tail_estimate=8.092194914091655e-6)
    tail mass 8.1e-06, aliasing <1e-10


A power-law tail never ends, so some mass is always beyond the grid. If the report shows too much, increase [log2](../reference/aggregate.GridAudit.md#prospicio.aggregate.GridAudit.log2) or truncate the severity ([Pareto](../reference/distributions.Pareto.md#prospicio.distributions.Pareto) takes a truncation point). With [alpha](../reference/models.ElasticNet.md#prospicio.models.ElasticNet.alpha) below 1 the mean is infinite and the sizing refuses:


``` python
try:
    fft_auto(freq, Pareto(0.5, 0.9), 12)
except ValueError as e:
    print(e)
```


    invalid parameter severity = inf: the aggregate mean must be finite and positive; choose the step by hand


A real book with such a tail has a policy limit (section 3.7).


## 3.6 Claims that cluster: a mixed Poisson count

One event can cause many claims (contagion), or the claim rate can be uncertain from year to year, so the count is more variable than a Poisson. A **mixed Poisson** count multiplies the rate by a random factor of mean 1; with the default gamma mixing, `Count.mixed_poisson(mean, cv)` is the negative binomial. FFT takes it directly:


``` python
mixed = Count.mixed_poisson(6.0, 0.5)  # rate factor with cv 0.5
mixed_annual, mixed_report, _ = fft_auto(mixed, sev, 12)
print(f"tail mass {mixed_report.tail_mass:.1e}, aliasing {tiny(mixed_report.aliasing_error)}")
```


    tail mass 1.9e-06, aliasing <1e-10


``` python
rows = [{"count": label, "var": c.variance(), "mean": a.mean(),
         "q99": a.quantile(0.99), "q995": a.quantile(0.995)}
        for label, c, a in (("Poisson", freq, annual), ("mixed Poisson", mixed, mixed_annual))]
(GT(pd.DataFrame(rows), rowname_col="count")
 .tab_header("Poisson against a mixed Poisson count", "Same mean count of 6; annual loss in money units")
 .cols_label(var="count variance", mean="annual mean", q99="99%", q995="99.5%")
 .fmt_number("var", decimals=1)
 .fmt_number(["mean"], decimals=3)
 .fmt_number(["q99", "q995"], decimals=2))
```


<style>
#zcdxhkoucj table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#zcdxhkoucj thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#zcdxhkoucj p { margin: 0; padding: 0; }
 #zcdxhkoucj .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #zcdxhkoucj .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #zcdxhkoucj .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #zcdxhkoucj .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #zcdxhkoucj .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #zcdxhkoucj .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #zcdxhkoucj .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #zcdxhkoucj .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #zcdxhkoucj .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #zcdxhkoucj .gt_column_spanner_outer:first-child { padding-left: 0; }
 #zcdxhkoucj .gt_column_spanner_outer:last-child { padding-right: 0; }
 #zcdxhkoucj .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #zcdxhkoucj .gt_spanner_row { border-bottom-style: hidden; }
 #zcdxhkoucj .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #zcdxhkoucj .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #zcdxhkoucj .gt_from_md> :first-child { margin-top: 0; }
 #zcdxhkoucj .gt_from_md> :last-child { margin-bottom: 0; }
 #zcdxhkoucj .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #zcdxhkoucj .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #zcdxhkoucj .gt_indent_1 { text-indent: 5px; }
 #zcdxhkoucj .gt_indent_2 { text-indent: calc(5px * 2); }
 #zcdxhkoucj .gt_indent_3 { text-indent: calc(5px * 3); }
 #zcdxhkoucj .gt_indent_4 { text-indent: calc(5px * 4); }
 #zcdxhkoucj .gt_indent_5 { text-indent: calc(5px * 5); }
 #zcdxhkoucj .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #zcdxhkoucj .gt_row_group_first td { border-top-width: 2px; }
 #zcdxhkoucj .gt_row_group_first th { border-top-width: 2px; }
 #zcdxhkoucj .gt_striped { color: #333333; background-color: #F4F4F4; }
 #zcdxhkoucj .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #zcdxhkoucj .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #zcdxhkoucj .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #zcdxhkoucj .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #zcdxhkoucj .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #zcdxhkoucj .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #zcdxhkoucj .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #zcdxhkoucj .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #zcdxhkoucj .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #zcdxhkoucj .gt_left { text-align: left; }
 #zcdxhkoucj .gt_center { text-align: center; }
 #zcdxhkoucj .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #zcdxhkoucj .gt_font_normal { font-weight: normal; }
 #zcdxhkoucj .gt_font_bold { font-weight: bold; }
 #zcdxhkoucj .gt_font_italic { font-style: italic; }
 #zcdxhkoucj .gt_super { font-size: 65%; }
 #zcdxhkoucj .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #zcdxhkoucj .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #zcdxhkoucj .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #zcdxhkoucj .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #zcdxhkoucj .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #zcdxhkoucj .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="5" id="title" class="gt_heading gt_title gt_font_normal">Poisson against a mixed Poisson count</th>
</tr>
<tr class="gt_heading">
<th colspan="5" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Same mean count of 6; annual loss in money units</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="var" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">count variance</th>
<th id="mean" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">annual mean</th>
<th id="q99" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99%</th>
<th id="q995" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99.5%</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Poisson</th>
<td class="gt_row gt_right" headers="stub-1 var">6.0</td>
<td class="gt_row gt_right" headers="stub-1 mean">6.000</td>
<td class="gt_row gt_right" headers="stub-1 q99">25.81</td>
<td class="gt_row gt_right" headers="stub-1 q995">31.56</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">mixed Poisson</th>
<td class="gt_row gt_right" headers="stub-2 var">15.0</td>
<td class="gt_row gt_right" headers="stub-2 mean">6.000</td>
<td class="gt_row gt_right" headers="stub-2 q99">28.56</td>
<td class="gt_row gt_right" headers="stub-2 q995">34.44</td>
</tr>
</tbody>
</table>


The mean is the same, and the 99.5% is higher. Claim sizes are still independent of each other and of the count. Dependence between size and number needs simulation or a scenario.


## 3.7 A policy limit or deductible on each claim

[fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) sizes its grid for the severity it gets. To cap each claim (or take off a deductible), discretize the unlimited severity yourself, then apply the term with [Grid.map](../reference/distributions.Grid.md#prospicio.distributions.Grid.map), which keeps the mean exactly. Here the cap is 10:


``` python
g, _ = Grid.local_moment(sev, 0.0625, 4096)
capped, on_points = g.map(lambda x: min(x, 10.0))
limited, limited_report = fft(freq, capped, 4096)
print(f"limited claim mean: grid {capped.mean():.4f}, exact {sev.lev(10.0):.4f}, on points {on_points}")
print(f"annual mean {limited.mean():.4f}, 99.5% {limited.quantile(0.995):.2f},"
      f" tail mass {tiny(limited_report.tail_mass)}")
```


    limited claim mean: grid 0.9527, exact 0.9527, on points True
    annual mean 5.7162, 99.5% 21.81, tail mass <1e-10


The grid's limited mean equals `sev.lev(10.0)`, and the cap pulls the 99.5% from 31.56 to 21.81. Put the limit on a grid point (here 10 is a multiple of the step): then [on_points](../reference/reinsurance.TowerGrids.md#prospicio.reinsurance.TowerGrids.on_points) is `True` and the shape, not only the mean, is exact. A deductible is `lambda x: max(x - d, 0.0)`.


# 4. Panjer: the exact check

Panjer's recursion computes the aggregate probabilities one point at a time. It is exact for the discretized problem and has no aliasing. Its work grows with the square of the grid length, against `n log n` for the FFT.


``` python
g, _ = Grid.local_moment(sev, 0.0625, 4096)
a_panjer, r_panjer = panjer(freq, g, 4096)
a_fft, r_fft = fft(freq, g, 4096)
gap = max(abs(x - y) for x, y in zip(a_panjer.probs, a_fft.probs))
print(f"largest difference between Panjer and FFT: {tiny(gap)}")
print(f"aliasing error: Panjer {r_panjer.aliasing_error}, FFT {tiny(r_fft.aliasing_error)}")
```


    largest difference between Panjer and FFT: <1e-10
    aliasing error: Panjer 0.0, FFT <1e-10


**Use Panjer** as an independent check of an FFT result on a small problem.

**Do not use it** for large counts or long grids. It needs a count from the families of the recursion: Poisson, negative binomial, binomial, and their zero-modified and zero-truncated versions ([Count.zero_truncated](../reference/distributions.Count.md#prospicio.distributions.Count.zero_truncated)). It refuses mixed Poisson counts and the Neyman type A. It fails for a large Poisson mean because the probability of a zero year, `exp(-mean)`, underflows:


``` python
panjer(Poisson(745.0), g, 4096)
print("Poisson 745: Panjer runs")
big = Poisson(800.0)
try:
    panjer(big, g, 4096)
except ValueError as e:
    print(e)
pig = Count.mixed_poisson(10.0, 0.5, mixing="inverse_gaussian")
try:
    panjer(pig, g, 4096)
except ValueError as e:
    print(e)
_, big_report = fft(big, g, 4096)
print(f"FFT on the same grid: tail_mass {big_report.tail_mass:.3f}")
big_annual, big_report, big_size = fft_auto(big, sev, 16)
print(f"fft_auto: step {big_size.step}, points {big_size.points}, mean {big_annual.mean():.1f},"
      f" tail mass {big_report.tail_mass:.1e}")
```


    Poisson 745: Panjer runs
    invalid parameter frequency = 800: P(S = 0) underflows for this claim count; use FFT
    invalid data: Panjer's recursion needs a count in the (a, b, 1) class; use FFT for this one
    FFT on the same grid: tail_mass 0.998
    fft_auto: step 0.03125, points 65536, mean 800.0, tail mass 1.7e-07


With 800 claims a year the annual mean is 800, far past a grid that reaches 256. [fft](../reference/aggregate.fft.md#prospicio.aggregate.fft) ran with no error: a [tail_mass](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.tail_mass) near 1 is the only warning (section 3.2). [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) sizes the grid for this book.


# 5. Simulation

[simulate_events](../reference/aggregate.simulate_events.md#prospicio.aggregate.simulate_events) draws many years (a claim count, then that many sizes) and keeps the individual losses in an [EventSet](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet), so per-loss terms (layers, sums insured, dates) apply afterwards.


``` python
events = simulate_events(freq, sev, 20_000, 1)
totals = events.totals()
print(events)
print(f"mean {totals.mean():.3f} (exact 6), 99.5% quantile {totals.quantile(0.995):.2f}"
      f" (FFT {annual.quantile(0.995):.2f})")
```


    EventSet(n_sims=20000, seed=1)
    mean 5.960 (exact 6), 99.5% quantile 30.57 (FFT 31.56)


**Use simulation** when the answer depends on the order, timing or identity of losses, or for several results at once (section 6), or when no grid can hold the problem: a catastrophe model's event loss table ([EventLossTable](../reference/aggregate.EventLossTable.md#prospicio.aggregate.EventLossTable)) or a severity that exists only as simulated losses. **Do not use it** for a tail quantile of a single book when FFT applies: the error is large and shrinks slowly.


## 5.1 Sampling error and seeds

A simulated number is random, and its error shrinks with the square root of the years. Ten seeds at two sizes, as average and standard deviation across seeds:


``` python
import statistics

rows = []
for n in (10_000, 100_000):
    runs = [simulate_events(freq, sev, n, seed).totals() for seed in range(1, 11)]
    qs = [t.quantile(0.995) for t in runs]
    ms = [t.mean() for t in runs]
    rows.append({"years": f"{n:,}", "q": statistics.mean(qs), "q_sd": statistics.stdev(qs),
                 "m": statistics.mean(ms), "m_sd": statistics.stdev(ms)})
(GT(pd.DataFrame(rows), rowname_col="years")
 .tab_header("Sampling error over ten seeds", f"The FFT gives {annual.quantile(0.995):.2f} for the 99.5% quantile and 6 for the mean")
 .tab_spanner("99.5% quantile", ["q", "q_sd"])
 .tab_spanner("mean", ["m", "m_sd"])
 .cols_label(q="average", q_sd="sd", m="average", m_sd="sd")
 .fmt_number(["q", "q_sd"], decimals=2)
 .fmt_number(["m", "m_sd"], decimals=3))
```


<style>
#etzavpcqwb table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#etzavpcqwb thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#etzavpcqwb p { margin: 0; padding: 0; }
 #etzavpcqwb .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #etzavpcqwb .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #etzavpcqwb .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #etzavpcqwb .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #etzavpcqwb .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #etzavpcqwb .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #etzavpcqwb .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #etzavpcqwb .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #etzavpcqwb .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #etzavpcqwb .gt_column_spanner_outer:first-child { padding-left: 0; }
 #etzavpcqwb .gt_column_spanner_outer:last-child { padding-right: 0; }
 #etzavpcqwb .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #etzavpcqwb .gt_spanner_row { border-bottom-style: hidden; }
 #etzavpcqwb .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #etzavpcqwb .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #etzavpcqwb .gt_from_md> :first-child { margin-top: 0; }
 #etzavpcqwb .gt_from_md> :last-child { margin-bottom: 0; }
 #etzavpcqwb .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #etzavpcqwb .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #etzavpcqwb .gt_indent_1 { text-indent: 5px; }
 #etzavpcqwb .gt_indent_2 { text-indent: calc(5px * 2); }
 #etzavpcqwb .gt_indent_3 { text-indent: calc(5px * 3); }
 #etzavpcqwb .gt_indent_4 { text-indent: calc(5px * 4); }
 #etzavpcqwb .gt_indent_5 { text-indent: calc(5px * 5); }
 #etzavpcqwb .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #etzavpcqwb .gt_row_group_first td { border-top-width: 2px; }
 #etzavpcqwb .gt_row_group_first th { border-top-width: 2px; }
 #etzavpcqwb .gt_striped { color: #333333; background-color: #F4F4F4; }
 #etzavpcqwb .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #etzavpcqwb .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #etzavpcqwb .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #etzavpcqwb .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #etzavpcqwb .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #etzavpcqwb .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #etzavpcqwb .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #etzavpcqwb .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #etzavpcqwb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #etzavpcqwb .gt_left { text-align: left; }
 #etzavpcqwb .gt_center { text-align: center; }
 #etzavpcqwb .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #etzavpcqwb .gt_font_normal { font-weight: normal; }
 #etzavpcqwb .gt_font_bold { font-weight: bold; }
 #etzavpcqwb .gt_font_italic { font-style: italic; }
 #etzavpcqwb .gt_super { font-size: 65%; }
 #etzavpcqwb .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #etzavpcqwb .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #etzavpcqwb .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #etzavpcqwb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #etzavpcqwb .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #etzavpcqwb .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="5" id="title" class="gt_heading gt_title gt_font_normal">Sampling error over ten seeds</th>
</tr>
<tr class="gt_heading">
<th colspan="5" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">The FFT gives 31.56 for the 99.5% quantile and 6 for the mean</th>
</tr>
<tr class="gt_col_headings gt_spanner_row">
<th rowspan="2" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th colspan="2" id="99.5-quantile" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">99.5% quantile</th>
<th colspan="2" id="mean" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">mean</th>
</tr>
<tr class="gt_col_headings">
<th id="q" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">average</th>
<th id="q_sd" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">sd</th>
<th id="m" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">average</th>
<th id="m_sd" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">sd</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">10,000</th>
<td class="gt_row gt_right" headers="stub-1 99.5-quantile q">31.55</td>
<td class="gt_row gt_right" headers="stub-1 99.5-quantile q_sd">1.42</td>
<td class="gt_row gt_right" headers="stub-1 mean m">6.001</td>
<td class="gt_row gt_right" headers="stub-1 mean m_sd">0.047</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">100,000</th>
<td class="gt_row gt_right" headers="stub-2 99.5-quantile q">31.68</td>
<td class="gt_row gt_right" headers="stub-2 99.5-quantile q_sd">0.51</td>
<td class="gt_row gt_right" headers="stub-2 mean m">6.004</td>
<td class="gt_row gt_right" headers="stub-2 mean m_sd">0.016</td>
</tr>
</tbody>
</table>


Ten times the years cut the error about threefold, not tenfold. A tail quantile is the noisiest number there is.


``` python
import matplotlib.pyplot as plt

draws = [row[0] for row in runs[0].draw_matrix()]
xs = [annual.step * i for i in range(len(annual.probs))]
density = [p / annual.step for p in annual.probs]
fig, ax = plt.subplots()
ax.hist(draws, bins=[0.5 * i for i in range(81)], density=True, color="0.75",
        label="simulation, 100,000 years")
ax.plot(xs, density, label="FFT")
ax.set_xlim(0, 40)
ax.set_xlabel("annual loss (money units)")
ax.set_ylabel("density")
ax.set_title("Annual loss of the running book: FFT against simulation")
ax.legend()
```


<figure class="p-figure figure">
MjA4LjQ5MDgxMiAKegoiIGNsaXAtcGF0aD0idXJsKCNwZWY4MDE3N2NjMikiIHN0eWxlPSJmaWxsOiBjb2xvci1taXgoaW4gc3JnYiwgdmFyKC0tcC1pbmspIDI1JSwgdHJhbnNwYXJlbnQpIiAvPgogICA8L2c+CiAgIDxnIGlkPSJwYXRjaF8zNCI+CiAgICA8cGF0aCBkPSJNIDIwNS4wNTA1NDcgMjIxLjkwMjEyNSAKTCAyMDkuOTMzMDQ3IDIyMS45MDIxMjUgCkwgMjA5LjkzMzA0NyAyMDguNjM1OTU2IApMIDIwNS4wNTA1NDcgMjA4LjYzNTk1NiAKegoiIGNsaXAtcGF0aD0idXJsKCNwZWY4MDE3N2NjMikiIHN0eWxlPSJmaWxsOiBjb2xvci1taXgoaW4g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yOTAuODA1MjM0IDU3LjA3NzI2NikiPkZGVDwvdGV4dD4KICAgIDwvZz4KICAgPC9nPgogIDwvZz4KIDwvZz4KIDxkZWZzPgogIDxjbGlwcGF0aCBpZD0icGVmODAxNzdjYzIiPgogICA8cmVjdCB4PSI1My42OTMwNDciIHk9IjIyLjMxODEyNSIgd2lkdGg9IjM5MC42IiBoZWlnaHQ9IjE5OS41ODQiIC8+CiAgPC9jbGlwcGF0aD4KIDwvZGVmcz4KPC9zdmc+" />
</figure>


A standard error from the sample variance (section 6) assumes a finite variance. For the Pareto of section 3.5 the variance is infinite, the error bar understates the noise and the mean settles slowly. Prefer the grid there.

The **seed** fixes the draws, for any number of threads (`docs/design/aggregate.md`, tested in the Rust crate). Each year has its own stream, so you can replay year `i` alone. Record the seed with every result.


``` python
a = simulate_events(freq, sev, 1000, 5)
b = simulate_events(freq, sev, 1000, 5)
c = simulate_events(freq, sev, 1000, 6)
print(a.totals().mean() == b.totals().mean(), a.totals().mean() == c.totals().mean())
print(a.events(0) == b.events(0), a.seed)
```


    True False
    True 5


`CollectiveModel(freq, sev).simulate(n, seed)` gives the same years from the pricing object. Other sources of years:

- [RiskProfile.simulate](../reference/pricing.RiskProfile.md#prospicio.pricing.RiskProfile.simulate) draws years from a property risk profile (section 6.2).
- [EventLossTable.simulate](../reference/aggregate.EventLossTable.md#prospicio.aggregate.EventLossTable.simulate) draws years from a catastrophe model's event loss table and returns the row of each loss.
- [EventSet.from_years](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.from_years) loads a list of losses for each year.
- [EventSet.from_long](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.from_long) loads one row for each loss with its year, the form of a year loss table.

A year loss table lists only the years with a loss. Give [from_long](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.from_long) the full `n_years`, including the years with no loss, or every frequency and loss cost comes out too high.


# 6. What each treaty pays

Two engines compute what a contract pays: [Tower.on_grid](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.on_grid) (exact FFT) and [Tower.apply](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.apply) (simulation).


## 6.1 Exactly on the grid

`Tower.on_grid(freq, severity_grid, points)` applies each layer's per-occurrence recovery to the severity grid, compounds the result with the same count, then applies the annual terms (annual deductible and limit, reinstatements, corridor) and the share to the annual total. It returns gross, each layer's ceded loss and, where it is one compound total, net. There is no sampling error.


``` python
program = Tower([
    Layer("5x5", 5.0, 5.0, reinstatements=1),
    Layer("10x10", 10.0, 10.0),
    Layer.quota_share("QS", 0.25),
])
g, _ = Grid.local_moment(sev, 0.0625, 4096)
grids = program.on_grid(freq, g, 4096)
rows = [{"layer": name, "mean": ceded.mean(), "q99": ceded.quantile(0.99)}
        for name, ceded in zip(program.layer_names, grids.ceded)]
(GT(pd.DataFrame(rows), rowname_col="layer")
 .tab_header("Ceded loss by layer, on the grid", "Mean and 99% quantile of the annual ceded loss, money units")
 .cols_label(mean="mean", q99="99%")
 .fmt_number("mean", decimals=4)
 .fmt_number("q99", decimals=3))
```


<style>
#yiziwoboiv table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#yiziwoboiv thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#yiziwoboiv p { margin: 0; padding: 0; }
 #yiziwoboiv .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #yiziwoboiv .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #yiziwoboiv .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #yiziwoboiv .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #yiziwoboiv .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #yiziwoboiv .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #yiziwoboiv .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #yiziwoboiv .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #yiziwoboiv .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #yiziwoboiv .gt_column_spanner_outer:first-child { padding-left: 0; }
 #yiziwoboiv .gt_column_spanner_outer:last-child { padding-right: 0; }
 #yiziwoboiv .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #yiziwoboiv .gt_spanner_row { border-bottom-style: hidden; }
 #yiziwoboiv .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #yiziwoboiv .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #yiziwoboiv .gt_from_md> :first-child { margin-top: 0; }
 #yiziwoboiv .gt_from_md> :last-child { margin-bottom: 0; }
 #yiziwoboiv .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #yiziwoboiv .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #yiziwoboiv .gt_indent_1 { text-indent: 5px; }
 #yiziwoboiv .gt_indent_2 { text-indent: calc(5px * 2); }
 #yiziwoboiv .gt_indent_3 { text-indent: calc(5px * 3); }
 #yiziwoboiv .gt_indent_4 { text-indent: calc(5px * 4); }
 #yiziwoboiv .gt_indent_5 { text-indent: calc(5px * 5); }
 #yiziwoboiv .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #yiziwoboiv .gt_row_group_first td { border-top-width: 2px; }
 #yiziwoboiv .gt_row_group_first th { border-top-width: 2px; }
 #yiziwoboiv .gt_striped { color: #333333; background-color: #F4F4F4; }
 #yiziwoboiv .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #yiziwoboiv .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #yiziwoboiv .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #yiziwoboiv .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #yiziwoboiv .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #yiziwoboiv .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #yiziwoboiv .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #yiziwoboiv .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #yiziwoboiv .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #yiziwoboiv .gt_left { text-align: left; }
 #yiziwoboiv .gt_center { text-align: center; }
 #yiziwoboiv .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #yiziwoboiv .gt_font_normal { font-weight: normal; }
 #yiziwoboiv .gt_font_bold { font-weight: bold; }
 #yiziwoboiv .gt_font_italic { font-style: italic; }
 #yiziwoboiv .gt_super { font-size: 65%; }
 #yiziwoboiv .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #yiziwoboiv .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #yiziwoboiv .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #yiziwoboiv .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #yiziwoboiv .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #yiziwoboiv .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="3" id="title" class="gt_heading gt_title gt_font_normal">Ceded loss by layer, on the grid</th>
</tr>
<tr class="gt_heading">
<th colspan="3" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Mean and 99% quantile of the annual ceded loss, money units</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="mean" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">mean</th>
<th id="q99" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99%</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">5x5</th>
<td class="gt_row gt_right" headers="stub-1 mean">0.4377</td>
<td class="gt_row gt_right" headers="stub-1 q99">5.000</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">10x10</th>
<td class="gt_row gt_right" headers="stub-2 mean">0.1956</td>
<td class="gt_row gt_right" headers="stub-2 q99">8.562</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">QS</th>
<td class="gt_row gt_right" headers="stub-3 mean">1.5000</td>
<td class="gt_row gt_right" headers="stub-3 q99">6.453</td>
</tr>
</tbody>
</table>


``` python
print("net available:", grids.net is not None, " on points:", grids.on_points)
plain = Tower([Layer("5x5", 5.0, 5.0)]).on_grid(freq, g, 4096)
stop_loss_last = Tower.inuring([[Layer("5x5", 5.0, 5.0)], [Layer.stop_loss("SL", 10.0, 10.0)]])
print("net without annual terms:", plain.net is not None,
      " net with a stop loss last:", stop_loss_last.on_grid(freq, g, 4096).net is not None)
```


    net available: False  on points: True
    net without annual terms: True  net with a stop loss last: True


[net](../reference/reinsurance.TowerGrids.md#prospicio.reinsurance.TowerGrids.net) is `None` because the 5x5 has an annual limit (from the reinstatement), so net would depend on several annual totals at once. Net exists when no layer has annual terms, or when the last stage is a single aggregate cover such as a stop loss. [on_points](../reference/reinsurance.TowerGrids.md#prospicio.reinsurance.TowerGrids.on_points) says whether every value fell on a grid point; if not, means are still exact but shapes smear by up to one step.

The same tower by simulation:


``` python
sim = program.apply(simulate_events(freq, sev, 100_000, 3))
rows = []
for name, ceded in zip(program.layer_names, grids.ceded):
    s = sim.marginal(("ceded", name))
    rows.append({"layer": name, "grid": ceded.mean(), "sim": s.mean(),
                 "se": s.variance() ** 0.5 / len(s) ** 0.5})
(GT(pd.DataFrame(rows), rowname_col="layer")
 .tab_header("Expected ceded loss: grid against simulation", "Money units, 100,000 simulated years")
 .cols_label(grid="grid", sim="simulated", se="standard error")
 .fmt_number(["grid", "sim", "se"], decimals=4))
```


<style>
#llaysglsby table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#llaysglsby thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#llaysglsby p { margin: 0; padding: 0; }
 #llaysglsby .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #llaysglsby .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #llaysglsby .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #llaysglsby .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #llaysglsby .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #llaysglsby .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #llaysglsby .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #llaysglsby .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #llaysglsby .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #llaysglsby .gt_column_spanner_outer:first-child { padding-left: 0; }
 #llaysglsby .gt_column_spanner_outer:last-child { padding-right: 0; }
 #llaysglsby .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #llaysglsby .gt_spanner_row { border-bottom-style: hidden; }
 #llaysglsby .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #llaysglsby .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #llaysglsby .gt_from_md> :first-child { margin-top: 0; }
 #llaysglsby .gt_from_md> :last-child { margin-bottom: 0; }
 #llaysglsby .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #llaysglsby .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #llaysglsby .gt_indent_1 { text-indent: 5px; }
 #llaysglsby .gt_indent_2 { text-indent: calc(5px * 2); }
 #llaysglsby .gt_indent_3 { text-indent: calc(5px * 3); }
 #llaysglsby .gt_indent_4 { text-indent: calc(5px * 4); }
 #llaysglsby .gt_indent_5 { text-indent: calc(5px * 5); }
 #llaysglsby .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #llaysglsby .gt_row_group_first td { border-top-width: 2px; }
 #llaysglsby .gt_row_group_first th { border-top-width: 2px; }
 #llaysglsby .gt_striped { color: #333333; background-color: #F4F4F4; }
 #llaysglsby .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #llaysglsby .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #llaysglsby .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #llaysglsby .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #llaysglsby .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #llaysglsby .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #llaysglsby .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #llaysglsby .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #llaysglsby .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #llaysglsby .gt_left { text-align: left; }
 #llaysglsby .gt_center { text-align: center; }
 #llaysglsby .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #llaysglsby .gt_font_normal { font-weight: normal; }
 #llaysglsby .gt_font_bold { font-weight: bold; }
 #llaysglsby .gt_font_italic { font-style: italic; }
 #llaysglsby .gt_super { font-size: 65%; }
 #llaysglsby .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #llaysglsby .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #llaysglsby .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #llaysglsby .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #llaysglsby .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #llaysglsby .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="4" id="title" class="gt_heading gt_title gt_font_normal">Expected ceded loss: grid against simulation</th>
</tr>
<tr class="gt_heading">
<th colspan="4" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Money units, 100,000 simulated years</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="grid" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">grid</th>
<th id="sim" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">simulated</th>
<th id="se" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">standard error</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">5x5</th>
<td class="gt_row gt_right" headers="stub-1 grid">0.4377</td>
<td class="gt_row gt_right" headers="stub-1 sim">0.4360</td>
<td class="gt_row gt_right" headers="stub-1 se">0.0041</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">10x10</th>
<td class="gt_row gt_right" headers="stub-2 grid">0.1956</td>
<td class="gt_row gt_right" headers="stub-2 sim">0.1952</td>
<td class="gt_row gt_right" headers="stub-2 se">0.0038</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">QS</th>
<td class="gt_row gt_right" headers="stub-3 grid">1.5000</td>
<td class="gt_row gt_right" headers="stub-3 sim">1.4985</td>
<td class="gt_row gt_right" headers="stub-3 se">0.0044</td>
</tr>
</tbody>
</table>


Publish the grid answer, which has no noise. Simulation is the check.


## 6.2 What forces simulation

A compound distribution does not record which loss came first, when it happened or how big the insured risk was, so terms that need those facts cannot run on the grid. [on_grid](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.on_grid) refuses the first three "No" rows with an error.

| Contract term | On the grid? | Why |
|----|----|----|
| Per-occurrence layer, share, quota share, stop loss | Yes | A function of each loss or of the annual total |
| Annual deductible and limit, reinstatements pro rata as to amount | Yes | Functions of the annual layer loss |
| Loss corridor | Yes | A function of the annual layer loss |
| Premium, ceding commission, sliding scale, profit commission, swing rating | Yes | Their expectations come from the ceded grid |
| Inuring stages without annual terms | Yes | Each stage is a function of each loss |
| Annual terms in a layer that inures to a later one | No | The later layer sees each loss net of the earlier one, which depends on event order |
| Reinstatement premium pro rata as to time | No | Needs the date of each loss |
| Surplus treaty | No | Cedes a share set by the sum insured of each risk |
| Joint distribution across layers or lines | No (a limit, not an error) | A grid is one marginal distribution |


``` python
timed = Layer("5x5", 5.0, 5.0, premium=1.0, reinstatement_rates=[1.0], pro_rata_time=True)
surplus = Layer.surplus("surplus", 1.0, 4.0)
inuring = Tower.inuring([[Layer("5x5", 5.0, 5.0, reinstatements=1)], [Layer("10x10", 10.0, 10.0)]])
for label, tw in (("pro rata as to time", Tower([timed])),
                  ("surplus", Tower([surplus])),
                  ("annual terms inuring", inuring)):
    try:
        tw.on_grid(freq, g, 4096)
    except ValueError as e:
        print(f"{label}: {str(e).split(': use')[0]}")
```


    pro rata as to time: invalid data: layer "5x5" has reinstatements pro rata as to time; a compound distribution has no event times
    surplus: invalid data: layer "surplus" is a surplus treaty, which works risk by risk; a compound distribution has no sums insured
    annual terms inuring: invalid parameter layers = 0: annual terms in a stage that inures to a later one depend on event order; use Tower::apply on simulated events


**Dates (pro rata as to time).** This reinstatement premium is lower when the layer uses its limit late in the year, so each loss needs a date. [with_uniform_times()](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.with_uniform_times) draws sorted uniform times; `with_seasonal_times(weights)` follows a season such as a hurricane year.


``` python
events = simulate_events(freq, sev, 20_000, 3).with_uniform_times()
by_amount = Layer("5x5", 5.0, 5.0, premium=1.0, reinstatement_rates=[1.0])
rows = []
for label, layer in (("as to amount, simulated", by_amount), ("as to time, simulated", timed)):
    result = Tower([layer]).apply(events)
    paid = result.marginal(("reinstatement_premium", "5x5"))
    rows.append({"basis": label, "premium": paid.mean(), "se": paid.variance() ** 0.5 / len(paid) ** 0.5})
grid_amount = Tower([by_amount]).on_grid(freq, g, 4096).expected_reinstatement_premium[0]
rows.append({"basis": "as to amount, on the grid", "premium": grid_amount, "se": None})
(GT(pd.DataFrame(rows), rowname_col="basis")
 .tab_header("Expected reinstatement premium", "Money units; layer 5 xs 5 with one reinstatement at 100%")
 .cols_label(premium="premium", se="standard error")
 .fmt_number(["premium", "se"], decimals=4)
 .sub_missing(missing_text=""))
```


<style>
#agvadamasq table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#agvadamasq thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#agvadamasq p { margin: 0; padding: 0; }
 #agvadamasq .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #agvadamasq .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #agvadamasq .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #agvadamasq .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #agvadamasq .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #agvadamasq .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #agvadamasq .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #agvadamasq .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #agvadamasq .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #agvadamasq .gt_column_spanner_outer:first-child { padding-left: 0; }
 #agvadamasq .gt_column_spanner_outer:last-child { padding-right: 0; }
 #agvadamasq .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #agvadamasq .gt_spanner_row { border-bottom-style: hidden; }
 #agvadamasq .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #agvadamasq .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #agvadamasq .gt_from_md> :first-child { margin-top: 0; }
 #agvadamasq .gt_from_md> :last-child { margin-bottom: 0; }
 #agvadamasq .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #agvadamasq .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #agvadamasq .gt_indent_1 { text-indent: 5px; }
 #agvadamasq .gt_indent_2 { text-indent: calc(5px * 2); }
 #agvadamasq .gt_indent_3 { text-indent: calc(5px * 3); }
 #agvadamasq .gt_indent_4 { text-indent: calc(5px * 4); }
 #agvadamasq .gt_indent_5 { text-indent: calc(5px * 5); }
 #agvadamasq .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #agvadamasq .gt_row_group_first td { border-top-width: 2px; }
 #agvadamasq .gt_row_group_first th { border-top-width: 2px; }
 #agvadamasq .gt_striped { color: #333333; background-color: #F4F4F4; }
 #agvadamasq .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #agvadamasq .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #agvadamasq .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #agvadamasq .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #agvadamasq .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #agvadamasq .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #agvadamasq .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #agvadamasq .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #agvadamasq .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #agvadamasq .gt_left { text-align: left; }
 #agvadamasq .gt_center { text-align: center; }
 #agvadamasq .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #agvadamasq .gt_font_normal { font-weight: normal; }
 #agvadamasq .gt_font_bold { font-weight: bold; }
 #agvadamasq .gt_font_italic { font-style: italic; }
 #agvadamasq .gt_super { font-size: 65%; }
 #agvadamasq .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #agvadamasq .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #agvadamasq .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #agvadamasq .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #agvadamasq .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #agvadamasq .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="3" id="title" class="gt_heading gt_title gt_font_normal">Expected reinstatement premium</th>
</tr>
<tr class="gt_heading">
<th colspan="3" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Money units; layer 5 xs 5 with one reinstatement at 100%</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="premium" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">premium</th>
<th id="se" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">standard error</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">as to amount, simulated</th>
<td class="gt_row gt_right" headers="stub-1 premium">0.0870</td>
<td class="gt_row gt_right" headers="stub-1 se">0.0018</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">as to time, simulated</th>
<td class="gt_row gt_right" headers="stub-2 premium">0.0440</td>
<td class="gt_row gt_right" headers="stub-2 se">0.0010</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">as to amount, on the grid</th>
<td class="gt_row gt_right" headers="stub-3 premium">0.0844</td>
<td class="gt_row gt_right" headers="stub-3 se"></td>
</tr>
</tbody>
</table>


Pro rata as to time roughly halves the premium, because an exhausting loss arrives on average half way through the year. The grid value is within two standard errors of the simulated by-amount premium.

**Sums insured (surplus).** A surplus treaty cedes a share set by the sum insured of the risk hit, so each event must carry one. [RiskProfile.simulate](../reference/pricing.RiskProfile.md#prospicio.pricing.RiskProfile.simulate) draws losses from a property risk profile (bands of sum insured, each with an exposure curve) and attaches the sums insured. Here the surplus inures to a per-risk excess of loss with a reinstatement, so two reasons apply at once.


``` python
profile = RiskProfile([1e6, 5e6, 20e6], [800, 120, 20], Mbbefd.swiss_re(3.0),
                      premiums=[3e6, 2.5e6, 1.5e6], loss_ratio=0.6)
treaty = Tower.inuring([
    [Layer.surplus("surplus", 2e6, 4.0)],
    [Layer("3x2", 3e6, 2e6, reinstatements=1)],
])
result = treaty.apply(profile.simulate(20_000, 5))
rows = [{"layer": name, "sim": result.marginal(("ceded", name)).mean(), "exact": exact}
        for name, exact in (("surplus", profile.expected_surplus_loss(2e6, 4.0)),
                            ("3x2", profile.expected_layer_loss(3e6, 2e6, 2e6, 4.0)))]
(GT(pd.DataFrame(rows), rowname_col="layer")
 .tab_header("Expected ceded loss: simulation against exposure rating", "Money units")
 .cols_label(sim="simulated", exact="exposure-rated")
 .fmt_integer(["sim", "exact"]))
```


<style>
#zxcinmoxtu table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#zxcinmoxtu thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#zxcinmoxtu p { margin: 0; padding: 0; }
 #zxcinmoxtu .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #zxcinmoxtu .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #zxcinmoxtu .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #zxcinmoxtu .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #zxcinmoxtu .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #zxcinmoxtu .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #zxcinmoxtu .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #zxcinmoxtu .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #zxcinmoxtu .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #zxcinmoxtu .gt_column_spanner_outer:first-child { padding-left: 0; }
 #zxcinmoxtu .gt_column_spanner_outer:last-child { padding-right: 0; }
 #zxcinmoxtu .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #zxcinmoxtu .gt_spanner_row { border-bottom-style: hidden; }
 #zxcinmoxtu .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #zxcinmoxtu .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #zxcinmoxtu .gt_from_md> :first-child { margin-top: 0; }
 #zxcinmoxtu .gt_from_md> :last-child { margin-bottom: 0; }
 #zxcinmoxtu .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #zxcinmoxtu .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #zxcinmoxtu .gt_indent_1 { text-indent: 5px; }
 #zxcinmoxtu .gt_indent_2 { text-indent: calc(5px * 2); }
 #zxcinmoxtu .gt_indent_3 { text-indent: calc(5px * 3); }
 #zxcinmoxtu .gt_indent_4 { text-indent: calc(5px * 4); }
 #zxcinmoxtu .gt_indent_5 { text-indent: calc(5px * 5); }
 #zxcinmoxtu .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #zxcinmoxtu .gt_row_group_first td { border-top-width: 2px; }
 #zxcinmoxtu .gt_row_group_first th { border-top-width: 2px; }
 #zxcinmoxtu .gt_striped { color: #333333; background-color: #F4F4F4; }
 #zxcinmoxtu .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #zxcinmoxtu .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #zxcinmoxtu .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #zxcinmoxtu .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #zxcinmoxtu .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #zxcinmoxtu .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #zxcinmoxtu .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #zxcinmoxtu .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #zxcinmoxtu .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #zxcinmoxtu .gt_left { text-align: left; }
 #zxcinmoxtu .gt_center { text-align: center; }
 #zxcinmoxtu .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #zxcinmoxtu .gt_font_normal { font-weight: normal; }
 #zxcinmoxtu .gt_font_bold { font-weight: bold; }
 #zxcinmoxtu .gt_font_italic { font-style: italic; }
 #zxcinmoxtu .gt_super { font-size: 65%; }
 #zxcinmoxtu .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #zxcinmoxtu .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #zxcinmoxtu .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #zxcinmoxtu .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #zxcinmoxtu .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #zxcinmoxtu .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="3" id="title" class="gt_heading gt_title gt_font_normal">Expected ceded loss: simulation against exposure rating</th>
</tr>
<tr class="gt_heading">
<th colspan="3" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Money units</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="sim" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">simulated</th>
<th id="exact" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">exposure-rated</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">surplus</th>
<td class="gt_row gt_right" headers="stub-1 sim">1,259,913</td>
<td class="gt_row gt_right" headers="stub-1 exact">1,260,000</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">3x2</th>
<td class="gt_row gt_right" headers="stub-2 sim">118,875</td>
<td class="gt_row gt_right" headers="stub-2 exact">117,525</td>
</tr>
</tbody>
</table>


The profile's exposure curves give an independent expected value (see [Experience and exposure rating](experience-and-exposure-rating.md)).

**Joint results.** [Tower.apply](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.apply) returns one joint distribution, so gross, every layer and net agree year by year (gross = ceded + net). The 99% of the sum of two layers, or dependence between lines, needs joint draws. To tie lines together with a copula or a rank correlation, see section 8 of [Choosing a method](choosing-a-method.md#8-capital-risk-measures-and-allocation) ([GaussianCopula](../reference/risk.GaussianCopula.md#prospicio.risk.GaussianCopula), [iman_conover](../reference/risk.iman_conover.md#prospicio.risk.iman_conover), [PredictiveDistribution](../reference/distributions.PredictiveDistribution.md#prospicio.distributions.PredictiveDistribution)). Reserves across lines use `SegmentDependence` ([Reserving methods](reserving-methods.md)).


# 7. The occurrence view

Many covers pay per occurrence: a catastrophe layer pays on each event, not on the sum of the year. Their curve is the **occurrence exceedance probability** (OEP): the probability that the *largest* loss of the year exceeds [x](../reference/distributions.Ogive.md#prospicio.distributions.Ogive.x). It is `1 - G_N(F(x))`, with `G_N` the generating function of the count. The **annual aggregate** curve is the probability that the *total* exceeds [x](../reference/distributions.Ogive.md#prospicio.distributions.Ogive.x). The **occurrence PML** (probable maximum loss) at annual probability [p](../reference/models.Elpd.md#prospicio.models.Elpd.p) is the loss whose OEP is [p](../reference/models.Elpd.md#prospicio.models.Elpd.p).


``` python
rows = []
for p in (0.1, 0.01):
    o = occurrence_pml(freq, sev, p)
    rows.append({"p": f"{p}", "pml": o.loss, "rp": o.annual_return_period,
                 "agg": annual.quantile(1 - p)})
(GT(pd.DataFrame(rows), rowname_col="p")
 .tab_header("Occurrence PML against the annual aggregate", "Money units, at annual exceedance probability p")
 .cols_label(pml="occurrence PML", rp="return period (years)", agg="annual aggregate")
 .fmt_number(["pml", "agg"], decimals=2)
 .fmt_integer("rp"))
```


<style>
#yhshaxnhpu table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#yhshaxnhpu thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#yhshaxnhpu p { margin: 0; padding: 0; }
 #yhshaxnhpu .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #yhshaxnhpu .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #yhshaxnhpu .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #yhshaxnhpu .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #yhshaxnhpu .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #yhshaxnhpu .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #yhshaxnhpu .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #yhshaxnhpu .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #yhshaxnhpu .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #yhshaxnhpu .gt_column_spanner_outer:first-child { padding-left: 0; }
 #yhshaxnhpu .gt_column_spanner_outer:last-child { padding-right: 0; }
 #yhshaxnhpu .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #yhshaxnhpu .gt_spanner_row { border-bottom-style: hidden; }
 #yhshaxnhpu .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #yhshaxnhpu .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #yhshaxnhpu .gt_from_md> :first-child { margin-top: 0; }
 #yhshaxnhpu .gt_from_md> :last-child { margin-bottom: 0; }
 #yhshaxnhpu .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #yhshaxnhpu .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #yhshaxnhpu .gt_indent_1 { text-indent: 5px; }
 #yhshaxnhpu .gt_indent_2 { text-indent: calc(5px * 2); }
 #yhshaxnhpu .gt_indent_3 { text-indent: calc(5px * 3); }
 #yhshaxnhpu .gt_indent_4 { text-indent: calc(5px * 4); }
 #yhshaxnhpu .gt_indent_5 { text-indent: calc(5px * 5); }
 #yhshaxnhpu .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #yhshaxnhpu .gt_row_group_first td { border-top-width: 2px; }
 #yhshaxnhpu .gt_row_group_first th { border-top-width: 2px; }
 #yhshaxnhpu .gt_striped { color: #333333; background-color: #F4F4F4; }
 #yhshaxnhpu .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #yhshaxnhpu .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #yhshaxnhpu .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #yhshaxnhpu .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #yhshaxnhpu .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #yhshaxnhpu .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #yhshaxnhpu .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #yhshaxnhpu .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #yhshaxnhpu .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #yhshaxnhpu .gt_left { text-align: left; }
 #yhshaxnhpu .gt_center { text-align: center; }
 #yhshaxnhpu .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #yhshaxnhpu .gt_font_normal { font-weight: normal; }
 #yhshaxnhpu .gt_font_bold { font-weight: bold; }
 #yhshaxnhpu .gt_font_italic { font-style: italic; }
 #yhshaxnhpu .gt_super { font-size: 65%; }
 #yhshaxnhpu .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #yhshaxnhpu .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #yhshaxnhpu .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #yhshaxnhpu .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #yhshaxnhpu .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #yhshaxnhpu .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="4" id="title" class="gt_heading gt_title gt_font_normal">Occurrence PML against the annual aggregate</th>
</tr>
<tr class="gt_heading">
<th colspan="4" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Money units, at annual exceedance probability p</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="pml" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">occurrence PML</th>
<th id="rp" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">return period (years)</th>
<th id="agg" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">annual aggregate</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">0.1</th>
<td class="gt_row gt_right" headers="stub-1 pml">6.48</td>
<td class="gt_row gt_right" headers="stub-1 rp">10</td>
<td class="gt_row gt_right" headers="stub-1 agg">11.94</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">0.01</th>
<td class="gt_row gt_right" headers="stub-2 pml">18.49</td>
<td class="gt_row gt_right" headers="stub-2 rp">100</td>
<td class="gt_row gt_right" headers="stub-2 agg">25.81</td>
</tr>
</tbody>
</table>


``` python
print(f"occurrence return period of the 1% loss: {o.occurrence_return_period:.1f} years")
print(f"P(largest claim > 5): {occurrence_exceedance(freq, sev, 5.0):.4f},"
      f" with the mixed Poisson count of 4.6: {occurrence_exceedance(mixed, sev, 5.0):.4f}")
print(f"simulated 1% occurrence PML: {simulate_events(freq, sev, 100_000, 3).maxima().quantile(0.99):.2f}")
```


    occurrence return period of the 1% loss: 99.5 years
    P(largest claim > 5): 0.1573, with the mixed Poisson count of 4.6: 0.1543
    simulated 1% occurrence PML: 18.54


The 1-in-100 annual aggregate is well above the 1-in-100 occurrence, because several claims add up. Use the occurrence curve for per-occurrence covers (catastrophe, per-risk layers), the aggregate curve for stop loss, aggregate limits and capital. The occurrence return period is the average time between occurrences above the loss. It is not 100 because a year can hold more than one occurrence.

For a Poisson count the OEP is `1 - exp(-6 (1 - F(x)))`, with `F` the severity cdf:


``` python
import math

grid = [0.25 * i for i in range(1, 161)]
oep = [1 - math.exp(-6.0 * (1 - sev.cdf(x))) for x in grid]
aep = [1 - annual.cdf(x) for x in grid]
fig, ax = plt.subplots()
ax.plot(grid, aep, label="annual aggregate (total of the year)")
ax.plot(grid, oep, label="occurrence (largest claim of the year)")
ax.set_yscale("log")
ax.set_ylim(1e-3, 1)
ax.set_xlabel("loss (money units)")
ax.set_ylabel("probability of exceeding the loss")
ax.set_title("Exceedance probability: occurrence against annual aggregate")
ax.legend()
```


<figure class="p-figure figure">
<img src="data:image/svg+xml;base64,PHN2ZyB4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjQ1Mi44NTA4NTlwdCIgaGVpZ2h0PSIyNjIuMTAyOTg0cHQiIHZpZXdib3g9IjAgMCA0NTIuODUwODU5IDI2Mi4xMDI5ODQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmVyc2lvbj0iMS4xIj4K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BpZD0ibGluZTJkXzU0Ij4KICAgICA8cGF0aCBkPSJNIDE5Ny4xOTAwNzggNTMuMjI3MjY2IApMIDIwOC4xOTAwNzggNTMuMjI3MjY2IApMIDIxOS4xOTAwNzggNTMuMjI3MjY2IAoiIHN0eWxlPSJmaWxsOiBub25lOyBzdHJva2U6IHZhcigtLXAtc2VyaWVzLTIpOyBzdHJva2Utd2lkdGg6IDEuNTsgc3Ryb2tlLWxpbmVjYXA6IHNxdWFyZSIgLz4KICAgIDwvZz4KICAgIDxnIGlkPSJ0ZXh0XzE4Ij4KICAgICA8dGV4dCBzdHlsZT0iZm9udC1zaXplOiAxMXB4OyBmb250LWZhbWlseTogdmFyKC0tcC1mb250KTsgdGV4dC1hbmNob3I6IHN0YXJ0OyBmaWxsOiB2YXIoLS1wLWluaykiIHg9IjIyNy45OTAwNzgiIHk9IjU3LjA3NzI2NiIgdHJhbnNmb3JtPSJyb3RhdGUoLTAgMjI3Ljk5MDA3OCA1Ny4wNzcyNjYpIj5vY2N1cnJlbmNlIChsYXJnZXN0IGNsYWltIG9mIHRoZSB5ZWFyKTwvdGV4dD4KICAgIDwvZz4KICAgPC9nPgogIDwvZz4KIDwvZz4KIDxkZWZzPgogIDxjbGlwcGF0aCBpZD0icDk3Mzg1ZTUyODAiPgogICA8cmVjdCB4PSI1NS4wNTA4NTkiIHk9IjIyLjMxODEyNSIgd2lkdGg9IjM5MC42IiBoZWlnaHQ9IjE5OS41ODQiIC8+CiAgPC9jbGlwcGF0aD4KIDwvZGVmcz4KPC9zdmc+" />
</figure>


The OEP is closed form for every count prospicio accepts. A more variable count makes a year with at least one claim above 5 slightly *less* likely (0.1543 against 0.1573 for the same mean), because more years have few or no claims, yet it makes the aggregate tail fatter (section 3.6). A simulation gives the same curve from [EventSet.maxima()](../reference/aggregate.EventSet.md#prospicio.aggregate.EventSet.maxima) (the largest loss of each year).

[occurrence_layer_statistics](../reference/reinsurance.occurrence_layer_statistics.md#prospicio.reinsurance.occurrence_layer_statistics) answers the layer questions in one call:


``` python
st = occurrence_layer_statistics(freq, g, 1.0, 5.0, 5.0)  # share, limit, attachment
rows = [("P(claim reaches layer)", st.pr_attach, 4), ("P(claim exhausts layer)", st.pr_detach, 4),
        ("P(loss in a year)", st.pr_loss, 4), ("loss on line", st.loss_on_line, 4),
        ("expected excess claims", st.count.mean, 4), ("mean layer loss per excess claim", st.severity.mean, 3),
        ("annual ceded: mean", st.aggregate.mean, 4), ("annual ceded: cv", st.aggregate.cv, 3),
        ("annual ceded: skew", st.aggregate.skew, 3)]
df = pd.DataFrame({"statistic": [r[0] for r in rows], "value": [r[1] for r in rows]})
tbl = GT(df, rowname_col="statistic").tab_header("The 5 xs 5 layer in one call", "occurrence_layer_statistics")
for d in (3, 4):
    tbl = tbl.fmt_number("value", rows=[i for i, r in enumerate(rows) if r[2] == d], decimals=d)
tbl
```


<style>
#ocnbyfdbns table {
          font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }

#ocnbyfdbns thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#ocnbyfdbns p { margin: 0; padding: 0; }
 #ocnbyfdbns .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }
 #ocnbyfdbns .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #ocnbyfdbns .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }
 #ocnbyfdbns .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }
 #ocnbyfdbns .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #ocnbyfdbns .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ocnbyfdbns .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }
 #ocnbyfdbns .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }
 #ocnbyfdbns .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }
 #ocnbyfdbns .gt_column_spanner_outer:first-child { padding-left: 0; }
 #ocnbyfdbns .gt_column_spanner_outer:last-child { padding-right: 0; }
 #ocnbyfdbns .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }
 #ocnbyfdbns .gt_spanner_row { border-bottom-style: hidden; }
 #ocnbyfdbns .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }
 #ocnbyfdbns .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }
 #ocnbyfdbns .gt_from_md> :first-child { margin-top: 0; }
 #ocnbyfdbns .gt_from_md> :last-child { margin-bottom: 0; }
 #ocnbyfdbns .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }
 #ocnbyfdbns .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }
 #ocnbyfdbns .gt_indent_1 { text-indent: 5px; }
 #ocnbyfdbns .gt_indent_2 { text-indent: calc(5px * 2); }
 #ocnbyfdbns .gt_indent_3 { text-indent: calc(5px * 3); }
 #ocnbyfdbns .gt_indent_4 { text-indent: calc(5px * 4); }
 #ocnbyfdbns .gt_indent_5 { text-indent: calc(5px * 5); }
 #ocnbyfdbns .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }
 #ocnbyfdbns .gt_row_group_first td { border-top-width: 2px; }
 #ocnbyfdbns .gt_row_group_first th { border-top-width: 2px; }
 #ocnbyfdbns .gt_striped { color: #333333; background-color: #F4F4F4; }
 #ocnbyfdbns .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ocnbyfdbns .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #ocnbyfdbns .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #ocnbyfdbns .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ocnbyfdbns .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #ocnbyfdbns .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #ocnbyfdbns .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #ocnbyfdbns .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #ocnbyfdbns .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #ocnbyfdbns .gt_left { text-align: left; }
 #ocnbyfdbns .gt_center { text-align: center; }
 #ocnbyfdbns .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #ocnbyfdbns .gt_font_normal { font-weight: normal; }
 #ocnbyfdbns .gt_font_bold { font-weight: bold; }
 #ocnbyfdbns .gt_font_italic { font-style: italic; }
 #ocnbyfdbns .gt_super { font-size: 65%; }
 #ocnbyfdbns .gt_footnotes { color: font-color(#FFFFFF); background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #ocnbyfdbns .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #ocnbyfdbns .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }
 #ocnbyfdbns .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #ocnbyfdbns .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #ocnbyfdbns .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" aria-describedby="subtitle" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="2" id="title" class="gt_heading gt_title gt_font_normal">The 5 xs 5 layer in one call</th>
</tr>
<tr class="gt_heading">
<th colspan="2" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">occurrence_layer_statistics</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="value" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">value</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">P(claim reaches layer)</th>
<td class="gt_row gt_right" headers="stub-1 value">0.0282</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">P(claim exhausts layer)</th>
<td class="gt_row gt_right" headers="stub-2 value">0.0072</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">P(loss in a year)</th>
<td class="gt_row gt_right" headers="stub-3 value">0.1557</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">loss on line</th>
<td class="gt_row gt_right" headers="stub-4 value">0.0876</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">expected excess claims</th>
<td class="gt_row gt_right" headers="stub-5 value">0.1692</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">mean layer loss per excess claim</th>
<td class="gt_row gt_right" headers="stub-6 value">2.589</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">annual ceded: mean</th>
<td class="gt_row gt_right" headers="stub-7 value">0.4381</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">annual ceded: cv</th>
<td class="gt_row gt_right" headers="stub-8 value">2.972</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">annual ceded: skew</th>
<td class="gt_row gt_right" headers="stub-9 value">3.383</td>
</tr>
</tbody>
</table>


The annual mean matches the [CollectiveModel](../reference/pricing.CollectiveModel.md#prospicio.pricing.CollectiveModel) value in section 1. [pr_loss](../reference/reinsurance.LayerStatistics.md#prospicio.reinsurance.LayerStatistics.pr_loss) is the OEP at the attachment: 0.1573 from [occurrence_exceedance](../reference/aggregate.occurrence_exceedance.md#prospicio.aggregate.occurrence_exceedance) on the continuous severity, 0.1557 on the grid.


# 8. Which method for which job

| Job | Use | Notes |
|----|----|----|
| Layer pricing (expected loss, loss on line, a risk load) | [CollectiveModel.layer_mean](../reference/pricing.CollectiveModel.md#prospicio.pricing.CollectiveModel.layer_mean), [occurrence_layer_statistics](../reference/reinsurance.occurrence_layer_statistics.md#prospicio.reinsurance.occurrence_layer_statistics), [Tower.on_grid](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.on_grid) | Closed form or FFT. Use [local_moment](../reference/distributions.Grid.md#prospicio.distributions.Grid.local_moment) so means are right. A distortion price needs the grid (`TowerGrids.price(distortion)` for the stand-alone price of each layer, or `price(grid, Distortion.tvar(p), cost_of_capital=r)` for any grid at a chosen capital standard). See [What a reinsurance price is](reinsurance-price.md) |
| Capital on one book (99% or 99.5% VaR or TVaR) | [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto), then the halving check | The grid is exact where simulation is noisy in the tail. Report [tail_mass](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.tail_mass) and [aliasing_error](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.aliasing_error) |
| Capital with dependence between lines or across treaties | Simulation, [PredictiveDistribution](../reference/distributions.PredictiveDistribution.md#prospicio.distributions.PredictiveDistribution), a copula | Needs joint draws ([Choosing a method](choosing-a-method.md#8-capital-risk-measures-and-allocation)). Fix the seed, use many years, report the standard error (section 5.1) |
| Reporting a result others must reproduce | FFT, with its report stored beside it | Deterministic. If you simulate, record the seed and [n_sims](../reference/esg.Scenarios.md#prospicio.esg.Scenarios.n_sims) |
| Sizing a catastrophe or per-risk limit | [occurrence_pml](../reference/aggregate.occurrence_pml.md#prospicio.aggregate.occurrence_pml), [occurrence_layer_statistics](../reference/reinsurance.occurrence_layer_statistics.md#prospicio.reinsurance.occurrence_layer_statistics) | The occurrence curve, not the annual total |

A grid gives both capital measures. TVaR at [p](../reference/models.Elpd.md#prospicio.models.Elpd.p) is the mean of the worst `1 - p` of years: the [p](../reference/models.Elpd.md#prospicio.models.Elpd.p) quantile plus `E[(S - q)+] / (1 - p)`. Solvency II asks for the 99.5% VaR, the Swiss Solvency Test for the 99% TVaR:


``` python
print(f"99.5% VaR {annual.quantile(0.995):.2f}, 99.5% TVaR {annual.tvar(0.995):.2f},"
      f" 99% TVaR {annual.tvar(0.99):.2f}")
```


    99.5% VaR 31.56, 99.5% TVaR 43.83, 99% TVaR 36.06


TVaR reaches further into the tail than a VaR, so [tail_mass](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.tail_mass) must be small beside `1 - p`. Run the halving check (section 3.4) on the TVaR itself.


# 9. Pitfalls

- **Reading [tail_mass](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.tail_mass) before [aliasing_error](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.aliasing_error).** Large aliasing hides wrapped mass in the grid, so [tail_mass](../reference/aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport.tail_mass) looks small.
- **A grid too short for the book, with no error.** [fft](../reference/aggregate.fft.md#prospicio.aggregate.fft) computes on the grid you give it (section 4, 800 claims). Use [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto) or check the report.
- **A [lower](../reference/distributions.Grid.md#prospicio.distributions.Grid.lower) grid for a price.** It is a lower bound by construction.
- **Trusting a quantile to the step.** A grid quantile is a grid point. Halve the step and judge a smooth number as well.
- **Moment fits in the tail.** They match three numbers and no more (section 2).
- **Comparing simulations on different seeds.** Keep the seed fixed when you compare two versions of a treaty, so the years differ only by your change.
- **Pricing a per-occurrence layer on the OEP.** The OEP gives the probability of a loss to the layer. The annual loss comes from the compound.
- **Adding layer grids.** You can add means, but not get the distribution of the sum, because the layers share the same losses. Use [Tower.apply](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.apply).


# See also

- [Choosing a method](choosing-a-method.md): which method fits which reinsurance question.
- [Risk loads and distortions](risk-loads-and-distortions.md): pricing the distributions this guide produces.
- [Experience and exposure rating](experience-and-exposure-rating.md): where the severity and the risk profile come from.
- [Severity and frequency](severity-and-frequency.md): choosing and fitting the inputs.
- [Reserving methods](reserving-methods.md): the other side of the actuary's work.
- [What a reinsurance price is](reinsurance-price.md): the price built from these distributions.
- [The aggregate design note](../design/aggregate.md) and [the `aggregate` parity reference](../../knowledge/references/aggregate-mildenhall.md): the design and the parity checks.


# Appendix: terms

- **Frequency** is the number of claims in a year, **severity** the size of one claim. The **aggregate loss** is their sum `S = X_1 + ... + X_N`, with claim sizes independent of each other and of `N`.
- **Per-occurrence** terms apply to each claim (an excess layer pays the part between its attachment and attachment plus limit). **Annual** terms apply to the total of the year (an annual deductible or limit, a stop loss).
- **Grid**: a distribution held as probabilities at `0, h, 2h, ...`, with **step** (bucket) `h`. FFT and Panjer **discretize** a continuous severity onto a grid, and that is their approximation.
- **Aliasing**: an FFT is circular, so probability beyond the end of its buffer wraps onto the start. **Tail mass** is the probability beyond the last grid point, which the grid puts on that point.
- **Seed**: the number that fixes the random draws of a simulation, so you can repeat a run.
