# A first course: from premium and losses to a priced book

Read this page first. It is for a student or a new analyst who knows what a premium and a claim are. It goes from a table of premium and losses to a price, and from prices to decisions. Each idea has a small example that you can run.

1.  **The ideas** (sections 1 to 7): loss distributions, the aggregate loss, price against expected loss, distortions, diversification and allocation.
2.  **Two decisions** (sections 8 and 9): write a new unit, and choose a treaty.
3.  **The checklist** (section 10): ten steps from data to a quote, with a template for your own data.

Money is in millions of a synthetic currency. All examples are synthetic. The appendix defines the terms.


# Part 1. The ideas


## 1. A loss is a distribution

Start with two small units. In a year, unit A loses 0, 4 or 10 with probability 1/2, 1/4 and 1/4. Unit B loses 0, 2 or 40 with the same probabilities. The units are independent, so the chances in 16 of a pair are the product of the chances in 4: the pair (0, 0) has 2 times 2 = 4. Each pair, repeated as many times as its chances, gives sixteen equally likely years.

[Sampled](../reference/distributions.Sampled.md#prospicio.distributions.Sampled) holds equally likely outcomes. Read `TVAR75.measure(x)` as the 75% TVaR of x (section 5 shows that TVaR is a distortion). This block has the imports for the page.


``` python
import math

import pandas as pd
from great_tables import GT
from prospicio.aggregate import fft, simulate_events
from prospicio.distributions import Grid, Lognormal, NegativeBinomial, Poisson, PredictiveDistribution, Sampled
from prospicio.pricing import Pentagon, Portfolio, Quote, price
from prospicio.reinsurance import Layer, Tower
from prospicio.risk import Distortion, GaussianCopula, capital, simulate

A = {0.0: 2, 4.0: 1, 10.0: 1}   # outcome: chances in 4
B = {0.0: 2, 2.0: 1, 40.0: 1}
rows = []
for a, n in A.items():
    for b, m in B.items():
        rows += [[a, b]] * (n * m)   # the pair (a, b) has n times m chances in 16
unit_a = Sampled([a for a, _ in rows])
unit_b = Sampled([b for _, b in rows])
total = Sampled([a + b for a, b in rows])
TVAR75 = Distortion.tvar(0.75)

tails = pd.DataFrame(
    [(name, x.mean(), x.quantile(0.75), TVAR75.measure(x)) for name, x in [("A", unit_a), ("B", unit_b), ("A + B", total)]],
    columns=["unit", "mean", "VaR 75%", "TVaR 75%"],
)
(GT(tails, rowname_col="unit")
 .tab_header("Mean and 75% tail measures of two independent units", "Millions")
 .fmt_number(["mean", "VaR 75%", "TVaR 75%"], decimals=2))
```


<style>
#kpvirdddpx 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;
        }

#kpvirdddpx thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#kpvirdddpx p { margin: 0; padding: 0; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #kpvirdddpx .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; }
 #kpvirdddpx .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; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #kpvirdddpx .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; }
 #kpvirdddpx .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; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_column_spanner_outer:first-child { padding-left: 0; }
 #kpvirdddpx .gt_column_spanner_outer:last-child { padding-right: 0; }
 #kpvirdddpx .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%; }
 #kpvirdddpx .gt_spanner_row { border-bottom-style: hidden; }
 #kpvirdddpx .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; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_from_md> :first-child { margin-top: 0; }
 #kpvirdddpx .gt_from_md> :last-child { margin-bottom: 0; }
 #kpvirdddpx .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; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_indent_1 { text-indent: 5px; }
 #kpvirdddpx .gt_indent_2 { text-indent: calc(5px * 2); }
 #kpvirdddpx .gt_indent_3 { text-indent: calc(5px * 3); }
 #kpvirdddpx .gt_indent_4 { text-indent: calc(5px * 4); }
 #kpvirdddpx .gt_indent_5 { text-indent: calc(5px * 5); }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_row_group_first td { border-top-width: 2px; }
 #kpvirdddpx .gt_row_group_first th { border-top-width: 2px; }
 #kpvirdddpx .gt_striped { color: #333333; background-color: #F4F4F4; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #kpvirdddpx .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #kpvirdddpx .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #kpvirdddpx .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #kpvirdddpx .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #kpvirdddpx .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #kpvirdddpx .gt_left { text-align: left; }
 #kpvirdddpx .gt_center { text-align: center; }
 #kpvirdddpx .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #kpvirdddpx .gt_font_normal { font-weight: normal; }
 #kpvirdddpx .gt_font_bold { font-weight: bold; }
 #kpvirdddpx .gt_font_italic { font-style: italic; }
 #kpvirdddpx .gt_super { font-size: 65%; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #kpvirdddpx .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; }
 #kpvirdddpx .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #kpvirdddpx .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #kpvirdddpx .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">Mean and 75% tail measures of two independent units</th>
</tr>
<tr class="gt_heading">
<th colspan="4" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions</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="VaR-75" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">VaR 75%</th>
<th id="TVaR-75" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">TVaR 75%</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">A</th>
<td class="gt_row gt_right" headers="stub-1 mean">3.50</td>
<td class="gt_row gt_right" headers="stub-1 VaR-75">4.00</td>
<td class="gt_row gt_right" headers="stub-1 TVaR-75">10.00</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">B</th>
<td class="gt_row gt_right" headers="stub-2 mean">10.50</td>
<td class="gt_row gt_right" headers="stub-2 VaR-75">2.00</td>
<td class="gt_row gt_right" headers="stub-2 TVaR-75">40.00</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">A + B</th>
<td class="gt_row gt_right" headers="stub-3 mean">14.00</td>
<td class="gt_row gt_right" headers="stub-3 VaR-75">12.00</td>
<td class="gt_row gt_right" headers="stub-3 TVaR-75">43.50</td>
</tr>
</tbody>
</table>


The means add: 3.5 + 10.5 = 14. The tails do not. B loses 40 in one year in four, above the 75% point, so its VaR is 2 and its TVaR is 40. A VaR shows where the bad years start, a TVaR how bad they are. The TVaR of the book is less than 50, the sum for A and B, because their worst years do not always occur together.


## 2. Adding independent risks

The loss of the book is the loss of A plus the loss of B. For independent units, the probability of a total is a sum over the pairs that give it: a total of 0 needs both units at 0, 1/2 times 1/2 = 4/16. [Portfolio](../reference/pricing.Portfolio.md#prospicio.pricing.Portfolio) does this for any table of outcomes.


``` python
port = Portfolio(["A", "B"], rows)
totals = pd.DataFrame({"total": [f"{t:.0f}" for t in port.totals], "chances": [round(16 * p) for p in port.probs]})
(GT(totals, rowname_col="total")
 .tab_header("The nine totals of the book", "Chances in 16")
 .fmt_integer("chances"))
```


<style>
#qhcejbddmb 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;
        }

#qhcejbddmb thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#qhcejbddmb p { margin: 0; padding: 0; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #qhcejbddmb .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; }
 #qhcejbddmb .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; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #qhcejbddmb .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; }
 #qhcejbddmb .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; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_column_spanner_outer:first-child { padding-left: 0; }
 #qhcejbddmb .gt_column_spanner_outer:last-child { padding-right: 0; }
 #qhcejbddmb .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%; }
 #qhcejbddmb .gt_spanner_row { border-bottom-style: hidden; }
 #qhcejbddmb .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; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_from_md> :first-child { margin-top: 0; }
 #qhcejbddmb .gt_from_md> :last-child { margin-bottom: 0; }
 #qhcejbddmb .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; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_indent_1 { text-indent: 5px; }
 #qhcejbddmb .gt_indent_2 { text-indent: calc(5px * 2); }
 #qhcejbddmb .gt_indent_3 { text-indent: calc(5px * 3); }
 #qhcejbddmb .gt_indent_4 { text-indent: calc(5px * 4); }
 #qhcejbddmb .gt_indent_5 { text-indent: calc(5px * 5); }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_row_group_first td { border-top-width: 2px; }
 #qhcejbddmb .gt_row_group_first th { border-top-width: 2px; }
 #qhcejbddmb .gt_striped { color: #333333; background-color: #F4F4F4; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #qhcejbddmb .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #qhcejbddmb .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #qhcejbddmb .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #qhcejbddmb .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #qhcejbddmb .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #qhcejbddmb .gt_left { text-align: left; }
 #qhcejbddmb .gt_center { text-align: center; }
 #qhcejbddmb .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #qhcejbddmb .gt_font_normal { font-weight: normal; }
 #qhcejbddmb .gt_font_bold { font-weight: bold; }
 #qhcejbddmb .gt_font_italic { font-style: italic; }
 #qhcejbddmb .gt_super { font-size: 65%; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #qhcejbddmb .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; }
 #qhcejbddmb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #qhcejbddmb .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #qhcejbddmb .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 nine totals of the book</th>
</tr>
<tr class="gt_heading">
<th colspan="2" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Chances in 16</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="chances" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">chances</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">0</th>
<td class="gt_row gt_right" headers="stub-1 chances">4</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">2</th>
<td class="gt_row gt_right" headers="stub-2 chances">2</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">4</th>
<td class="gt_row gt_right" headers="stub-3 chances">2</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">6</th>
<td class="gt_row gt_right" headers="stub-4 chances">1</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">10</th>
<td class="gt_row gt_right" headers="stub-5 chances">2</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">12</th>
<td class="gt_row gt_right" headers="stub-6 chances">1</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">40</th>
<td class="gt_row gt_right" headers="stub-7 chances">2</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">44</th>
<td class="gt_row gt_right" headers="stub-8 chances">1</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">50</th>
<td class="gt_row gt_right" headers="stub-9 chances">1</td>
</tr>
</tbody>
</table>


This calculation is a **convolution**. Thousands of claims need a tool, the next section.


## 3. The aggregate loss: count times severity, by FFT

A real line has a random number of claims (the **frequency**) and a random size for each claim (the **severity**). Their sum for the year is the **aggregate loss**. The library puts the severity on a grid of equally spaced points and adds the claims with the fast Fourier transform (FFT). Here the mean claim is 1 with a CV of 1.5, and the mean count is 10 claims a year.


``` python
severity, _ = Grid.rounding(Lognormal.from_mean_cv(1.0, 1.5), 0.05, 801)   # claim sizes on a 0.05 step, up to 40
year, report = fft(Poisson(10.0), severity, 2**12)                          # 4,096 points: totals up to 204.8
print(f"mean claim {severity.mean():.3f}, mean year {year.mean():.2f}, sd {math.sqrt(year.variance()):.2f}")
print(f"99% VaR {year.quantile(0.99):.2f}, 99% TVaR {year.tvar(0.99):.2f}")
print(f"aliasing error below 1e-12: {report.aliasing_error < 1e-12}, tail mass below 1e-12: {report.tail_mass < 1e-12}")
```


    mean claim 0.999, mean year 9.99, sd 5.65
    99% VaR 28.70, 99% TVaR 34.91
    aliasing error below 1e-12: True, tail mass below 1e-12: True


The right tail of the year is long: the 99% VaR is almost three times the mean.


``` python
import matplotlib.pyplot as plt

x = [year.step * i for i in range(len(year.probs))]
fig, ax = plt.subplots()
ax.plot(x, [q / year.step for q in year.probs], label="aggregate loss of the year")
ax.axvline(year.mean(), color="0.5", linestyle=":", label="mean")
ax.axvline(year.quantile(0.99), color="0.3", linestyle="--", label="99% VaR")
ax.axvline(year.tvar(0.99), color="0.3", linestyle="-.", label="99% TVaR")
ax.set_xlim(0, 50)
ax.set_xlabel("loss in the year (millions)")
ax.set_ylabel("probability density")
ax.set_title("The aggregate loss: 10 claims a year on average, CV 1.5 each")
ax.legend(loc="center right")
```


<figure class="p-figure figure">
<img src="data:image/svg+xml;base64,PHN2ZyB4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjQ1OC40OTE3OTdwdCIgaGVpZ2h0PSIyNjIuMTAyOTg0cHQiIHZpZXdib3g9IjAgMCA0NTguNDkxNzk3IDI2Mi4xMDI5ODQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmVyc2lvbj0iMS4xIj4KIDxtZXRhZGF0YT4KICA8cmRmIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6Y2M9Imh0dHA6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL25zIyIgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgPHdvcms+CiAgICA8dHlwZSByZGY6cmVzb3VyY2U9Imh0dHA6Ly9wdXJsLm9yZy9kYy9kY21pdHlwZS9TdGlsbEltYWdlIj48L3R5cGU+CiAgICA8ZGF0ZT4yMDI2LTExLTI5VDE3OjIwOjUwLjY1Mzc0MTwvZGF0ZT4KICAgIDxmb3JtYXQ+aW1hZ2Uvc3ZnK3htbDwvZm9ybWF0PgogICAgPGNyZWF0b3I+CiAgICAgPGFnZW50PgogICAgICA8dGl0bGU+TWF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Hk9IjIyLjMxODEyNSIgd2lkdGg9IjM5MC42IiBoZWlnaHQ9IjE5OS41ODQiIC8+CiAgPC9jbGlwcGF0aD4KIDwvZGVmcz4KPC9zdmc+" />
</figure>


Two checks are important. The FFT wraps any probability past the end of the grid back to the start (**aliasing**). The **tail mass** is the probability that stays past the grid. Both must be very small, or the tail that you price is wrong. If they are not, use more points or a larger step; [audit_grid](../reference/aggregate.audit_grid.md#prospicio.aggregate.audit_grid) selects them for you (section 10).


## 4. Why a price must exceed the mean

Go back to the book of section 1. An insurer that charges only the expected loss, 14, makes no profit on average, and it still needs capital for the bad years. The owners supply that capital only for a return. Let the assets be the 75% TVaR, 43.5, and let the owners want 10%. Then the premium P must give a margin of 10% of the capital: P - 14 = 10% of (43.5 - P).

The **pricing pentagon** solves this equation. It connects loss, premium, margin, capital and assets; any three set the other two.


``` python
book = Pentagon.solve(loss=total.mean(), assets=TVAR75.measure(total), return_on_capital=0.10)
print(f"loss {book.loss:.2f}  premium {book.premium:.2f}  margin {book.margin:.2f}  "
      f"capital {book.capital:.2f}  assets {book.assets:.2f}  loss ratio {book.loss_ratio:.1%}")
```


    loss 14.00  premium 16.68  margin 2.68  capital 26.82  assets 43.50  loss ratio 83.9%


The price is above the mean because capital has a cost: a riskier cover needs more capital, so more margin. The [pentagon section of the price guide](reinsurance-price.md#the-pricing-pentagon) has the formula.


## 5. What a distortion is

A distortion prices the loss directly, with no capital standard. It replaces each probability s of a loss above a value with a larger probability, g(s), so bad outcomes count for more than their probability. The proportional hazard distortion is g(s) = s to the power 0.5. For four equally likely outcomes it gives one weight to each outcome, smallest first. The price is the weighted sum.


``` python
ph = Distortion.proportional_hazard(0.5)
print("g(s) at s = 0.25, 0.5, 0.75: " + ", ".join(f"{ph.g(s):.3f}" for s in (0.25, 0.5, 0.75)))
w = ph.weights(4)
print("weights of 4 equally likely outcomes, smallest first: " + ", ".join(f"{x:.3f}" for x in w))
print(f"A as 0, 0, 4, 10 by hand: {w[2] * 4 + w[3] * 10:.2f}")
```


    g(s) at s = 0.25, 0.5, 0.75: 0.500, 0.707, 0.866
    weights of 4 equally likely outcomes, smallest first: 0.134, 0.159, 0.207, 0.500
    A as 0, 0, 4, 10 by hand: 5.83


The distortion prices a chance of one in four as one in two, so the worst of four outcomes gets weight 0.5, not 0.25. The prices:


``` python
ph_prices = pd.DataFrame(
    [(name, x.mean(), ph.measure(x)) for name, x in [("A", unit_a), ("B", unit_b), ("A + B", total)]],
    columns=["unit", "expected loss", "price"],
)
ph_prices.loc[len(ph_prices)] = ["A's plus B's", ph_prices["expected loss"][:2].sum(), ph_prices["price"][:2].sum()]
(GT(ph_prices, rowname_col="unit")
 .tab_header("Proportional hazard price, g(s) = s^0.5", "Millions")
 .fmt_number(["expected loss", "price"], decimals=2))
```


<style>
#tyuxrwdzso 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;
        }

#tyuxrwdzso thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#tyuxrwdzso p { margin: 0; padding: 0; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_column_spanner_outer:first-child { padding-left: 0; }
 #tyuxrwdzso .gt_column_spanner_outer:last-child { padding-right: 0; }
 #tyuxrwdzso .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%; }
 #tyuxrwdzso .gt_spanner_row { border-bottom-style: hidden; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_from_md> :first-child { margin-top: 0; }
 #tyuxrwdzso .gt_from_md> :last-child { margin-bottom: 0; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_indent_1 { text-indent: 5px; }
 #tyuxrwdzso .gt_indent_2 { text-indent: calc(5px * 2); }
 #tyuxrwdzso .gt_indent_3 { text-indent: calc(5px * 3); }
 #tyuxrwdzso .gt_indent_4 { text-indent: calc(5px * 4); }
 #tyuxrwdzso .gt_indent_5 { text-indent: calc(5px * 5); }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_row_group_first td { border-top-width: 2px; }
 #tyuxrwdzso .gt_row_group_first th { border-top-width: 2px; }
 #tyuxrwdzso .gt_striped { color: #333333; background-color: #F4F4F4; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #tyuxrwdzso .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #tyuxrwdzso .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #tyuxrwdzso .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #tyuxrwdzso .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #tyuxrwdzso .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #tyuxrwdzso .gt_left { text-align: left; }
 #tyuxrwdzso .gt_center { text-align: center; }
 #tyuxrwdzso .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #tyuxrwdzso .gt_font_normal { font-weight: normal; }
 #tyuxrwdzso .gt_font_bold { font-weight: bold; }
 #tyuxrwdzso .gt_font_italic { font-style: italic; }
 #tyuxrwdzso .gt_super { font-size: 65%; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #tyuxrwdzso .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; }
 #tyuxrwdzso .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #tyuxrwdzso .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #tyuxrwdzso .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">Proportional hazard price, g(s) = s^0.5</th>
</tr>
<tr class="gt_heading">
<th colspan="3" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="expected-loss" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">expected loss</th>
<th id="price" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">price</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">A</th>
<td class="gt_row gt_right" headers="stub-1 expected-loss">3.50</td>
<td class="gt_row gt_right" headers="stub-1 price">5.83</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">B</th>
<td class="gt_row gt_right" headers="stub-2 expected-loss">10.50</td>
<td class="gt_row gt_right" headers="stub-2 price">20.41</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">A + B</th>
<td class="gt_row gt_right" headers="stub-3 expected-loss">14.00</td>
<td class="gt_row gt_right" headers="stub-3 price">25.41</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">A's plus B's</th>
<td class="gt_row gt_right" headers="stub-4 expected-loss">14.00</td>
<td class="gt_row gt_right" headers="stub-4 price">26.24</td>
</tr>
</tbody>
</table>


The book costs less than A and B priced apart: pricing the two units together already gives a discount.

In the figure, the grey line is no distortion. Proportional hazard lies above it everywhere. The TVaR curve rises straight to 1 at s = 0.25, so all the weight is on the worst quarter.


``` python
ss = [i / 200 for i in range(201)]
fig, ax = plt.subplots()
ax.plot(ss, ss, color="0.75", label="no distortion, g(s) = s")
ax.plot(ss, [ph.g(v) for v in ss], label="proportional hazard 0.5")
ax.plot(ss, [TVAR75.g(v) for v in ss], label="TVaR 75%")
ax.set_xlabel("s, the probability of a loss above a value")
ax.set_ylabel("g(s), the distorted probability")
ax.set_title("A distortion raises the probability of bad outcomes")
ax.legend()
```


<figure class="p-figure figure">
SJ4dGlja18yIj4KICAgICA8ZyBpZD0ibGluZTJkXzMiPgogICAgICA8cGF0aCBkPSJNIDEzNS40NjcwMjQgMjIxLjkwMjEyNSAKTCAxMzUuNDY3MDI0IDIyLjMxODEyNSAKIiBjbGlwLXBhdGg9InVybCgjcDMzY2EyMDdmZjMpIiBzdHlsZT0iZmlsbDogbm9uZTsgc3Ryb2tlOiB2YXIoLS1wLXJ1bGUpOyBzdHJva2Utd2lkdGg6IDAuODsgc3Ryb2tlLWxpbmVjYXA6IHNxdWFyZSIgLz4KICAgICA8L2c+CiAgICAgPGcgaWQ9ImxpbmUyZF80Ij4KICAgICAgPGc+CiAgICAgICA8dXNl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0iZm9udC1zaXplOiAxMXB4OyBmb250LWZhbWlseTogdmFyKC0tcC1mb250KTsgdGV4dC1hbmNob3I6IHN0YXJ0OyBmaWxsOiB2YXIoLS1wLWluaykiIHg9IjI5OC4yNzMyMDMiIHk9IjIwOS4zNTk1NDciIHRyYW5zZm9ybT0icm90YXRlKC0wIDI5OC4yNzMyMDMgMjA5LjM1OTU0NykiPlRWYVIgNzUlPC90ZXh0PgogICAgPC9nPgogICA8L2c+CiAgPC9nPgogPC9nPgogPGRlZnM+CiAgPGNsaXBwYXRoIGlkPSJwMzNjYTIwN2ZmMyI+CiAgIDxyZWN0IHg9IjQ2LjY5NDI5NyIgeT0iMjIuMzE4MTI1IiB3aWR0aD0iMzkwLjYiIGhlaWdodD0iMTk5LjU4NCIgLz4KICA8L2NsaXBwYXRoPgogPC9kZWZzPgo8L3N2Zz4=" />
</figure>


## 6. Why a book's price is not the sum of its parts

A book is also cheaper than its parts because it needs less capital. [price_stand_alone](../reference/pricing.Portfolio.md#prospicio.pricing.Portfolio.price_stand_alone) prices each unit as a separate book, with assets at its own 90% VaR, and compares them with the full book, with assets at the 90% VaR of the book. This section uses a VaR standard, not the 75% TVaR of section 4. A VaR standard leaves the book a small chance of default, and the section shows the effect of that chance.


``` python
sa = port.price_stand_alone(ph, 0.9)
parts = [(f"{name} alone", alone.assets, alone.premium) for name, alone in zip(sa.units, sa.stand_alone)]
parts += [("sum of the parts", sa.sum.assets, sa.sum.premium), ("the book", sa.total.assets, sa.total.premium)]
parts += [("diversification benefit", sa.sum.assets - sa.total.assets, sa.sum.premium - sa.total.premium)]
(GT(pd.DataFrame(parts, columns=["price", "assets", "premium"]), rowname_col="price")
 .tab_header("Stand-alone and book prices at the 90% VaR standard", "Proportional hazard 0.5, millions")
 .fmt_number(["assets", "premium"], decimals=2))
```


<style>
#djaeaatewk 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;
        }

#djaeaatewk thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#djaeaatewk p { margin: 0; padding: 0; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #djaeaatewk .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; }
 #djaeaatewk .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; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #djaeaatewk .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; }
 #djaeaatewk .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; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_column_spanner_outer:first-child { padding-left: 0; }
 #djaeaatewk .gt_column_spanner_outer:last-child { padding-right: 0; }
 #djaeaatewk .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%; }
 #djaeaatewk .gt_spanner_row { border-bottom-style: hidden; }
 #djaeaatewk .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; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_from_md> :first-child { margin-top: 0; }
 #djaeaatewk .gt_from_md> :last-child { margin-bottom: 0; }
 #djaeaatewk .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; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_indent_1 { text-indent: 5px; }
 #djaeaatewk .gt_indent_2 { text-indent: calc(5px * 2); }
 #djaeaatewk .gt_indent_3 { text-indent: calc(5px * 3); }
 #djaeaatewk .gt_indent_4 { text-indent: calc(5px * 4); }
 #djaeaatewk .gt_indent_5 { text-indent: calc(5px * 5); }
 #djaeaatewk .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; }
 #djaeaatewk .gt_row_group_first td { border-top-width: 2px; }
 #djaeaatewk .gt_row_group_first th { border-top-width: 2px; }
 #djaeaatewk .gt_striped { color: #333333; background-color: #F4F4F4; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #djaeaatewk .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #djaeaatewk .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #djaeaatewk .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #djaeaatewk .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #djaeaatewk .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #djaeaatewk .gt_left { text-align: left; }
 #djaeaatewk .gt_center { text-align: center; }
 #djaeaatewk .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #djaeaatewk .gt_font_normal { font-weight: normal; }
 #djaeaatewk .gt_font_bold { font-weight: bold; }
 #djaeaatewk .gt_font_italic { font-style: italic; }
 #djaeaatewk .gt_super { font-size: 65%; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #djaeaatewk .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; }
 #djaeaatewk .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #djaeaatewk .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #djaeaatewk .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">Stand-alone and book prices at the 90% VaR standard</th>
</tr>
<tr class="gt_heading">
<th colspan="3" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Proportional hazard 0.5, millions</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="assets" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">assets</th>
<th id="premium" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">premium</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">A alone</th>
<td class="gt_row gt_right" headers="stub-1 assets">10.00</td>
<td class="gt_row gt_right" headers="stub-1 premium">5.83</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">B alone</th>
<td class="gt_row gt_right" headers="stub-2 assets">40.00</td>
<td class="gt_row gt_right" headers="stub-2 premium">20.41</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">sum of the parts</th>
<td class="gt_row gt_right" headers="stub-3 assets">50.00</td>
<td class="gt_row gt_right" headers="stub-3 premium">26.24</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">the book</th>
<td class="gt_row gt_right" headers="stub-4 assets">44.00</td>
<td class="gt_row gt_right" headers="stub-4 premium">23.91</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">diversification benefit</th>
<td class="gt_row gt_right" headers="stub-5 assets">6.00</td>
<td class="gt_row gt_right" headers="stub-5 premium">2.34</td>
</tr>
</tbody>
</table>


Alone, A holds 10 and B holds 40, a sum of 50. The book total reaches 50 in one year in sixteen only, so at the 90% standard the book holds 44.

The premium decreases in two steps:

1.  The distortion alone decreases the 26.24 of the parts to 25.41 (section 5). That 0.83 is pure pooling.
2.  With assets of 44, the book can pay at most 44 (limited liability), so its premium prices that smaller loss: 23.91. That 1.50 is not pooling: the book defaults in the one year in sixteen with a total of 50, and its policyholders bear the 6 that it cannot pay.

The full difference of 2.34 is the **diversification benefit**. The next section asks which unit gets it.


## 7. The main allocation methods

To judge each unit, an analyst splits the premium and the assets of the book. Each method answers a different question. [capital](../reference/risk.capital.md#prospicio.risk.capital) splits the 75% TVaR of the book, 43.5, by four methods. [Portfolio.price](../reference/pricing.Portfolio.md#prospicio.pricing.Portfolio.price) splits the proportional hazard premium by the **natural allocation**: each unit has the book's distortion weights, outcome by outcome, so the unit premiums add up to the book's.


``` python
pdist = PredictiveDistribution(["unit"], [("A",), ("B",)], rows)
rows_t = []
for method in ["euler", "covariance", "shapley", "marginal"]:
    al = capital(pdist, TVAR75, method)
    rows_t.append((method, al.allocated[0], al.allocated[1], sum(al.allocated)))
rows_t.append(("stand-alone", al.standalone[0], al.standalone[1], sum(al.standalone)))
natural = port.price(ph).to_dict()
rows_t.append(("natural PH (premium)", natural["premium"][0], natural["premium"][1], natural["premium"][2]))
alloc = pd.DataFrame(rows_t, columns=["method", "A", "B", "sum"])
(GT(alloc, rowname_col="method")
 .tab_header("Allocation of the book's 75% TVaR of assets, 43.50, to units A and B",
             "Millions; the last row splits the premium, not the assets")
 .fmt_number(["A", "B", "sum"], decimals=2))
```


<style>
#npkczjjoyk 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;
        }

#npkczjjoyk thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#npkczjjoyk p { margin: 0; padding: 0; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #npkczjjoyk .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; }
 #npkczjjoyk .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; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #npkczjjoyk .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; }
 #npkczjjoyk .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; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_column_spanner_outer:first-child { padding-left: 0; }
 #npkczjjoyk .gt_column_spanner_outer:last-child { padding-right: 0; }
 #npkczjjoyk .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%; }
 #npkczjjoyk .gt_spanner_row { border-bottom-style: hidden; }
 #npkczjjoyk .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; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_from_md> :first-child { margin-top: 0; }
 #npkczjjoyk .gt_from_md> :last-child { margin-bottom: 0; }
 #npkczjjoyk .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; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_indent_1 { text-indent: 5px; }
 #npkczjjoyk .gt_indent_2 { text-indent: calc(5px * 2); }
 #npkczjjoyk .gt_indent_3 { text-indent: calc(5px * 3); }
 #npkczjjoyk .gt_indent_4 { text-indent: calc(5px * 4); }
 #npkczjjoyk .gt_indent_5 { text-indent: calc(5px * 5); }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_row_group_first td { border-top-width: 2px; }
 #npkczjjoyk .gt_row_group_first th { border-top-width: 2px; }
 #npkczjjoyk .gt_striped { color: #333333; background-color: #F4F4F4; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #npkczjjoyk .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #npkczjjoyk .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #npkczjjoyk .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #npkczjjoyk .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #npkczjjoyk .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #npkczjjoyk .gt_left { text-align: left; }
 #npkczjjoyk .gt_center { text-align: center; }
 #npkczjjoyk .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #npkczjjoyk .gt_font_normal { font-weight: normal; }
 #npkczjjoyk .gt_font_bold { font-weight: bold; }
 #npkczjjoyk .gt_font_italic { font-style: italic; }
 #npkczjjoyk .gt_super { font-size: 65%; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #npkczjjoyk .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; }
 #npkczjjoyk .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #npkczjjoyk .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #npkczjjoyk .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">Allocation of the book's 75% TVaR of assets, 43.50, to units A and B</th>
</tr>
<tr class="gt_heading">
<th colspan="4" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions; the last row splits the premium, not the assets</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="A" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">A</th>
<th id="B" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">B</th>
<th id="sum" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">sum</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">euler</th>
<td class="gt_row gt_right" headers="stub-1 A">3.50</td>
<td class="gt_row gt_right" headers="stub-1 B">40.00</td>
<td class="gt_row gt_right" headers="stub-1 sum">43.50</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">covariance</th>
<td class="gt_row gt_right" headers="stub-2 A">2.37</td>
<td class="gt_row gt_right" headers="stub-2 B">41.13</td>
<td class="gt_row gt_right" headers="stub-2 sum">43.50</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">shapley</th>
<td class="gt_row gt_right" headers="stub-3 A">6.75</td>
<td class="gt_row gt_right" headers="stub-3 B">36.75</td>
<td class="gt_row gt_right" headers="stub-3 sum">43.50</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">marginal</th>
<td class="gt_row gt_right" headers="stub-4 A">3.50</td>
<td class="gt_row gt_right" headers="stub-4 B">33.50</td>
<td class="gt_row gt_right" headers="stub-4 sum">37.00</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">stand-alone</th>
<td class="gt_row gt_right" headers="stub-5 A">10.00</td>
<td class="gt_row gt_right" headers="stub-5 B">40.00</td>
<td class="gt_row gt_right" headers="stub-5 sum">50.00</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">natural PH (premium)</th>
<td class="gt_row gt_right" headers="stub-6 A">5.05</td>
<td class="gt_row gt_right" headers="stub-6 B">20.36</td>
<td class="gt_row gt_right" headers="stub-6 sum">25.41</td>
</tr>
</tbody>
</table>


| Method | The question it answers |
|----|----|
| Euler (coTVaR) | What does each unit lose, on average, in the worst years of the book? This is the coTVaR of the unit. In those years the mean loss of A is 3.5, its own mean |
| Covariance | How much does each unit move with the total? It can give a unit less than its mean |
| Shapley | What does each unit add, on average over all orders in which you can build the book? |
| Marginal | How much does the TVaR of the book decrease without the unit? The parts do not add up to the total (37 of 43.5) |
| Natural allocation | The share of each unit in the distorted price, outcome by outcome. The shares add up, and A pays 5.05 for an expected loss of 3.5 |

No method is correct for all questions. Select the method for the question, and say which you used. Never compare the return of one unit under one method with that of another unit under a different method. [Section 8 of choosing a method](choosing-a-method.md#8-capital-risk-measures-and-allocation) runs these methods on a simulated book; [the price allocation guide](pir-price-allocation.md) has more.


# Part 2. Two decisions


## 8. Should we write a new unit?

An insurer writes motor and home. A broker offers a block of storm-exposed commercial property for a premium of 7.3. Should the insurer write it? We ask the same question for a second insurer that writes motor and liability.

The FFT gives the annual loss of each line from a count and a claim size capped at the policy limit:


``` python
STEP, POINTS = 0.1, 2**12


def line(frequency, severity, cap):
    """A line's annual loss on the grid: claims capped at the policy limit, then the FFT."""
    claims, _ = Grid.rounding(severity, STEP, round(cap / STEP) + 1)
    return fft(frequency, claims, POINTS)[0]


motor = line(NegativeBinomial.from_mean_variance(100, 150), Lognormal.from_mean_cv(0.4, 1.0), 10)
home = line(Poisson(8), Lognormal.from_mean_cv(1.5, 2.5), 40)
liability = line(Poisson(3), Lognormal.from_mean_cv(3.0, 2.0), 40)
storm = line(Poisson(4), Lognormal.from_mean_cv(1.5, 2.5), 40)   # the new unit: storm-exposed commercial property
lines_t = pd.DataFrame(
    [(n, g.mean(), g.quantile(0.99)) for n, g in [("motor", motor), ("home", home), ("liability", liability), ("new unit", storm)]],
    columns=["line", "mean", "99% VaR"],
)
(GT(lines_t, rowname_col="line")
 .tab_header("Annual loss of each line", "Millions")
 .fmt_number("mean", decimals=2)
 .fmt_number("99% VaR", decimals=1))
```


<style>
#jetnqauilo 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;
        }

#jetnqauilo thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#jetnqauilo p { margin: 0; padding: 0; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #jetnqauilo .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; }
 #jetnqauilo .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; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #jetnqauilo .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; }
 #jetnqauilo .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; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_column_spanner_outer:first-child { padding-left: 0; }
 #jetnqauilo .gt_column_spanner_outer:last-child { padding-right: 0; }
 #jetnqauilo .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%; }
 #jetnqauilo .gt_spanner_row { border-bottom-style: hidden; }
 #jetnqauilo .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; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_from_md> :first-child { margin-top: 0; }
 #jetnqauilo .gt_from_md> :last-child { margin-bottom: 0; }
 #jetnqauilo .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; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_indent_1 { text-indent: 5px; }
 #jetnqauilo .gt_indent_2 { text-indent: calc(5px * 2); }
 #jetnqauilo .gt_indent_3 { text-indent: calc(5px * 3); }
 #jetnqauilo .gt_indent_4 { text-indent: calc(5px * 4); }
 #jetnqauilo .gt_indent_5 { text-indent: calc(5px * 5); }
 #jetnqauilo .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; }
 #jetnqauilo .gt_row_group_first td { border-top-width: 2px; }
 #jetnqauilo .gt_row_group_first th { border-top-width: 2px; }
 #jetnqauilo .gt_striped { color: #333333; background-color: #F4F4F4; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #jetnqauilo .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #jetnqauilo .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #jetnqauilo .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #jetnqauilo .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #jetnqauilo .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #jetnqauilo .gt_left { text-align: left; }
 #jetnqauilo .gt_center { text-align: center; }
 #jetnqauilo .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #jetnqauilo .gt_font_normal { font-weight: normal; }
 #jetnqauilo .gt_font_bold { font-weight: bold; }
 #jetnqauilo .gt_font_italic { font-style: italic; }
 #jetnqauilo .gt_super { font-size: 65%; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #jetnqauilo .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; }
 #jetnqauilo .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #jetnqauilo .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #jetnqauilo .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">Annual loss of each line</th>
</tr>
<tr class="gt_heading">
<th colspan="3" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions</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="99-VaR" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">99% VaR</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">motor</th>
<td class="gt_row gt_right" headers="stub-1 mean">40.03</td>
<td class="gt_row gt_right" headers="stub-1 99-VaR">56.1</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">home</th>
<td class="gt_row gt_right" headers="stub-2 mean">11.76</td>
<td class="gt_row gt_right" headers="stub-2 99-VaR">48.2</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">liability</th>
<td class="gt_row gt_right" headers="stub-3 mean">8.73</td>
<td class="gt_row gt_right" headers="stub-3 99-VaR">45.9</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">new unit</th>
<td class="gt_row gt_right" headers="stub-4 mean">5.88</td>
<td class="gt_row gt_right" headers="stub-4 99-VaR">35.8</td>
</tr>
</tbody>
</table>


The lines are not independent. A storm hits home and commercial property in the same year, so the new unit has a copula correlation of 0.7 with home. Liability has no relation to the weather: 0. Motor has 0.1 with all lines. [simulate](../reference/risk.simulate.md#prospicio.risk.simulate) draws 10,000 years from the lines, joined by a Gaussian copula, a standard method to put dependence on given distributions. Its correlation is that of the normal scores behind the draws. The correlation of the losses is smaller.

First, the book of today. The insurer holds assets at the 99% TVaR of its total and wants a 10% return on capital. [Portfolio.calibrate](../reference/pricing.Portfolio.md#prospicio.pricing.Portfolio.calibrate) finds the Wang distortion that gives exactly that premium (Wang has one parameter, lambda: a higher lambda makes risk more expensive). We keep it as the **price of risk** of the company, the charge of its investors for risk of any type.


``` python
N, SEED, RETURN = 10_000, 2026, 0.10
TAIL = Distortion.tvar(0.99)   # the capital standard: assets = 99% TVaR of the book's total


def book_of(lines, correlation, keys):
    """Simulate the lines joined by a Gaussian copula: the draws, the Portfolio and its assets."""
    pd = simulate(GaussianCopula(correlation), lines, N, SEED, keys=[(k,) for k in keys], dims=["line"])
    return pd, Portfolio.from_predictive(pd), TAIL.measure(pd)


pd2, p2, a2 = book_of([motor, home], [[1.0, 0.1], [0.1, 1.0]], ["motor", "home"])
house = p2.calibrate("wang", assets=a2, return_on_capital=RETURN)
today = p2.price(house, assets=a2).to_dict()
print(f"motor + home: assets {a2:.1f}, Wang lambda {house.parameters['lambda']:.3f}")
```


    motor + home: assets 100.5, Wang lambda 0.365


``` python
book_t = pd.DataFrame({"line": today["unit"], "loss": today["loss"], "premium": today["premium"],
                       "capital": today["capital"], "return": today["return_on_capital"]})
(GT(book_t, rowname_col="line")
 .tab_header("The book of today, calibrated to a 10% return", "Millions")
 .fmt_number(["loss", "premium", "capital"], decimals=2)
 .fmt_percent("return", decimals=1))
```


<style>
#udntgonmbb 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;
        }

#udntgonmbb thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#udntgonmbb p { margin: 0; padding: 0; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #udntgonmbb .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; }
 #udntgonmbb .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; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #udntgonmbb .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; }
 #udntgonmbb .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; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_column_spanner_outer:first-child { padding-left: 0; }
 #udntgonmbb .gt_column_spanner_outer:last-child { padding-right: 0; }
 #udntgonmbb .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%; }
 #udntgonmbb .gt_spanner_row { border-bottom-style: hidden; }
 #udntgonmbb .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; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_from_md> :first-child { margin-top: 0; }
 #udntgonmbb .gt_from_md> :last-child { margin-bottom: 0; }
 #udntgonmbb .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; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_indent_1 { text-indent: 5px; }
 #udntgonmbb .gt_indent_2 { text-indent: calc(5px * 2); }
 #udntgonmbb .gt_indent_3 { text-indent: calc(5px * 3); }
 #udntgonmbb .gt_indent_4 { text-indent: calc(5px * 4); }
 #udntgonmbb .gt_indent_5 { text-indent: calc(5px * 5); }
 #udntgonmbb .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; }
 #udntgonmbb .gt_row_group_first td { border-top-width: 2px; }
 #udntgonmbb .gt_row_group_first th { border-top-width: 2px; }
 #udntgonmbb .gt_striped { color: #333333; background-color: #F4F4F4; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #udntgonmbb .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #udntgonmbb .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #udntgonmbb .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #udntgonmbb .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #udntgonmbb .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #udntgonmbb .gt_left { text-align: left; }
 #udntgonmbb .gt_center { text-align: center; }
 #udntgonmbb .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #udntgonmbb .gt_font_normal { font-weight: normal; }
 #udntgonmbb .gt_font_bold { font-weight: bold; }
 #udntgonmbb .gt_font_italic { font-style: italic; }
 #udntgonmbb .gt_super { font-size: 65%; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #udntgonmbb .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; }
 #udntgonmbb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #udntgonmbb .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #udntgonmbb .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 book of today, calibrated to a 10% return</th>
</tr>
<tr class="gt_heading">
<th colspan="5" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="loss" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">loss</th>
<th id="premium" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">premium</th>
<th id="capital" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">capital</th>
<th id="return" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">return</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">motor</th>
<td class="gt_row gt_right" headers="stub-1 loss">40.10</td>
<td class="gt_row gt_right" headers="stub-1 premium">41.56</td>
<td class="gt_row gt_right" headers="stub-1 capital">16.97</td>
<td class="gt_row gt_right" headers="stub-1 return">8.6%</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">home</th>
<td class="gt_row gt_right" headers="stub-2 loss">11.73</td>
<td class="gt_row gt_right" headers="stub-2 premium">14.69</td>
<td class="gt_row gt_right" headers="stub-2 capital">27.24</td>
<td class="gt_row gt_right" headers="stub-2 return">10.9%</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">total</th>
<td class="gt_row gt_right" headers="stub-3 loss">51.83</td>
<td class="gt_row gt_right" headers="stub-3 premium">56.25</td>
<td class="gt_row gt_right" headers="stub-3 capital">44.21</td>
<td class="gt_row gt_right" headers="stub-3 return">10.0%</td>
</tr>
</tbody>
</table>


Motor is large but steady, and gets little capital. Home has a heavy tail, and gets most of the capital.

Now add the new unit to each book, and price the larger book with the same distortion. The **marginal premium** is the increase in the Wang premium of the book. A lower premium pays the owners less than the company's price of risk. The table also shows the allocated premium, the premium that keeps the larger book at a flat 10% on its 99% TVaR assets, and two splits of the assets.


``` python
OFFERED = 7.3
results = {}
for name, lines, r_new in [("motor + home", [motor, home], (0.1, 0.7)),
                           ("motor + liability", [motor, liability], (0.1, 0.0))]:
    keys = name.split(" + ")
    _, p2, a2 = book_of(lines, [[1.0, 0.1], [0.1, 1.0]], keys)
    house = p2.calibrate("wang", assets=a2, return_on_capital=RETURN)   # each insurer calibrates its own book
    pd3, p3, a3 = book_of(lines + [storm], [[1.0, 0.1, r_new[0]], [0.1, 1.0, r_new[1]], [r_new[0], r_new[1], 1.0]],
                          keys + ["new"])
    before, after = p2.price(house, assets=a2).total, p3.price(house, assets=a3)
    results[name] = {
        "expected loss": after.allocated[2].loss,
        "allocated premium": after.allocated[2].premium,
        "marginal premium": after.total.premium - before.premium,
        "premium for 10%": Pentagon.solve(loss=after.total.loss, assets=a3, return_on_capital=RETURN).premium
                           - before.premium,
        "allocated assets": after.allocated[2].assets,
        "Shapley assets": capital(pd3, TAIL, "shapley").allocated[2],
        "marginal assets": a3 - a2,
        "return at 7.3": Pentagon.solve(loss=after.total.loss, premium=before.premium + OFFERED,
                                        assets=a3).return_on_capital,
    }

cols = list(results)
new_unit = pd.DataFrame(results).rename_axis("measure").reset_index()
(GT(new_unit, rowname_col="measure")
 .tab_header("The new unit in each book", f"Millions; offered premium {OFFERED}")
 .fmt_number(cols, rows=list(range(7)), decimals=2)
 .fmt_percent(cols, rows=[7], decimals=1))
```


<style>
#vojtxyazoj 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;
        }

#vojtxyazoj thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#vojtxyazoj p { margin: 0; padding: 0; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #vojtxyazoj .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; }
 #vojtxyazoj .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; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #vojtxyazoj .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; }
 #vojtxyazoj .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; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_column_spanner_outer:first-child { padding-left: 0; }
 #vojtxyazoj .gt_column_spanner_outer:last-child { padding-right: 0; }
 #vojtxyazoj .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%; }
 #vojtxyazoj .gt_spanner_row { border-bottom-style: hidden; }
 #vojtxyazoj .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; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_from_md> :first-child { margin-top: 0; }
 #vojtxyazoj .gt_from_md> :last-child { margin-bottom: 0; }
 #vojtxyazoj .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; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_indent_1 { text-indent: 5px; }
 #vojtxyazoj .gt_indent_2 { text-indent: calc(5px * 2); }
 #vojtxyazoj .gt_indent_3 { text-indent: calc(5px * 3); }
 #vojtxyazoj .gt_indent_4 { text-indent: calc(5px * 4); }
 #vojtxyazoj .gt_indent_5 { text-indent: calc(5px * 5); }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_row_group_first td { border-top-width: 2px; }
 #vojtxyazoj .gt_row_group_first th { border-top-width: 2px; }
 #vojtxyazoj .gt_striped { color: #333333; background-color: #F4F4F4; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #vojtxyazoj .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #vojtxyazoj .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #vojtxyazoj .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #vojtxyazoj .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #vojtxyazoj .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #vojtxyazoj .gt_left { text-align: left; }
 #vojtxyazoj .gt_center { text-align: center; }
 #vojtxyazoj .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #vojtxyazoj .gt_font_normal { font-weight: normal; }
 #vojtxyazoj .gt_font_bold { font-weight: bold; }
 #vojtxyazoj .gt_font_italic { font-style: italic; }
 #vojtxyazoj .gt_super { font-size: 65%; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #vojtxyazoj .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; }
 #vojtxyazoj .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #vojtxyazoj .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #vojtxyazoj .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">The new unit in each book</th>
</tr>
<tr class="gt_heading">
<th colspan="3" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions; offered premium 7.3</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="motor-home" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">motor + home</th>
<th id="motor-liability" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">motor + liability</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">expected loss</th>
<td class="gt_row gt_right" headers="stub-1 motor-home">5.79</td>
<td class="gt_row gt_right" headers="stub-1 motor-liability">5.82</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">allocated premium</th>
<td class="gt_row gt_right" headers="stub-2 motor-home">7.72</td>
<td class="gt_row gt_right" headers="stub-2 motor-liability">7.19</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">marginal premium</th>
<td class="gt_row gt_right" headers="stub-3 motor-home">7.47</td>
<td class="gt_row gt_right" headers="stub-3 motor-liability">6.61</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">premium for 10%</th>
<td class="gt_row gt_right" headers="stub-4 motor-home">8.11</td>
<td class="gt_row gt_right" headers="stub-4 motor-liability">6.32</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">allocated assets</th>
<td class="gt_row gt_right" headers="stub-5 motor-home">27.87</td>
<td class="gt_row gt_right" headers="stub-5 motor-liability">18.96</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">Shapley assets</th>
<td class="gt_row gt_right" headers="stub-6 motor-home">34.92</td>
<td class="gt_row gt_right" headers="stub-6 motor-liability">25.35</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">marginal assets</th>
<td class="gt_row gt_right" headers="stub-7 motor-home">31.42</td>
<td class="gt_row gt_right" headers="stub-7 motor-liability">11.26</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">return at 7.3</th>
<td class="gt_row gt_right" headers="stub-8 motor-home">8.7%</td>
<td class="gt_row gt_right" headers="stub-8 motor-liability">12.2%</td>
</tr>
</tbody>
</table>


``` python
for name, r in results.items():
    print(f"offered {OFFERED:.2f} in {name}: {'write' if OFFERED >= r['marginal premium'] else 'decline'}")
```


    offered 7.30 in motor + home: decline
    offered 7.30 in motor + liability: write


**The decision.** The same unit at the same price gets opposite answers. In the motor and home book it adds 31.42 of assets, because its storms occur with the storms of home, and the Wang premium rises by 7.47: 7.3 is too little, so decline or ask for at least 7.5. In the motor and liability book it adds only 11.26 of assets and the Wang premium rises by 6.61: 7.3 is enough, so write it.

The two criteria in the table do not agree, so select the one that controls the decision. A flat 10% on the assets of the larger book (the constant cost of capital distortion) prices each unit of extra capital the same. Wang charges less for the far tail and more for the moderate years. The storm adds much tail to the motor and home book, so the flat hurdle asks more than Wang. It adds little tail to the motor and liability book, so the hurdle asks less.

This page uses the calibrated Wang price, because it prices all risks on the same terms. Say so when you report the decision. An insurer that uses the flat hurdle should ask for 8.11 for motor and home.

There are two lessons:

1.  The price of a unit depends on the book that it joins. There is no single correct premium for it.
2.  The allocated premium is not the marginal premium. An allocation shares the diversification of the full book. The marginal premium measures only the change that the unit causes, so use it to add or remove a unit.


## 9. Choosing a treaty for one cedant

A cedant writes 100 of premium. It expects 40 claims a year (negative binomial, variance 80), with mean 1.3 and CV 3, capped at a policy limit of 25. It must select a reinsurance structure.

This cedant measures capital as a solvency regulator does: the 99.5% VaR of its yearly cost minus the mean. Its owners want 16% on that capital. The reinsurer prices with a 10% return on its own 99% TVaR, then adds expenses and brokerage. Reinsurance pays when it costs less than 16% of the capital that it releases.


``` python
PREMIUM, LIMIT = 100.0, 25.0
frequency = NegativeBinomial.from_mean_variance(40, 80)
claims, _ = Grid.rounding(Lognormal.from_mean_cv(1.3, 3.0), STEP, round(LIMIT / STEP) + 1)   # capped at 25
gross, report = fft(frequency, claims, POINTS)
HURDLE = 0.16   # the cedant's cost of capital


def cedant_capital(g):
    """The cedant's capital: the 99.5% VaR of its cost less the mean."""
    return g.quantile(0.995) - g.mean()


GROSS_CAPITAL = cedant_capital(gross)
print(f"gross: expected loss {gross.mean():.2f}, 99.5% VaR {gross.quantile(0.995):.1f}, capital {GROSS_CAPITAL:.2f}")
print(f"aliasing error below 1e-12: {report.aliasing_error < 1e-12}")
```


    gross: expected loss 49.28, 99.5% VaR 114.8, capital 65.52
    aliasing error below 1e-12: True


### Excess of loss: which attachment and limit?

[Tower.on_grid](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.on_grid) gives the annual loss of a layer ([ceded](../reference/reinsurance.Layer.md#prospicio.reinsurance.Layer.ceded)) and the net loss of the cedant ([net](../reference/reinsurance.TowerGrids.md#prospicio.reinsurance.TowerGrids.net)) on the same grid. [price](../reference/pricing.price.md#prospicio.pricing.price) gives the risk premium of the reinsurer. [Quote.technical](../reference/pricing.Quote.md#prospicio.pricing.Quote.technical) adds 5% expenses and 10% brokerage to it. In the tables, **ceded** is the expected loss that the layer pays, **premium** is what the cedant pays for it, **cost** is the premium minus the expected recoveries, and **saved** is the capital that the cedant saves. **Cost %** is the cost per unit of capital saved. **Value** is 16% of the capital saved minus the cost; a positive value means that the cover costs less than the capital.


``` python
ROWS = {}


def record(name, ceded_loss, premium, cost, saved):
    ROWS[name] = {"ceded": ceded_loss, "premium": premium, "cost": cost, "saved": saved}


def structure_table(names, title, drop=()):
    """The recorded structures as a table, with the cost per unit of capital saved and the value."""
    df = pd.DataFrame([{"structure": n, **ROWS[n], "cost %": ROWS[n]["cost"] / ROWS[n]["saved"],
                        "value": HURDLE * ROWS[n]["saved"] - ROWS[n]["cost"]} for n in names]).drop(columns=list(drop))
    numbers = [c for c in df.columns if c not in ("structure", "cost %")]
    return (GT(df, rowname_col="structure")
            .tab_header(title, "Millions; value = 16% of the capital saved, minus the cost")
            .fmt_number(numbers, decimals=2)
            .fmt_percent("cost %", decimals=1))


xl_quotes = {}
for limit, attachment in [(23, 2), (20, 5), (10, 5), (15, 10)]:
    xl = Layer(f"XL {limit}x{attachment}", float(limit), float(attachment))
    t = Tower([xl]).on_grid(frequency, claims, POINTS)
    q = Quote.technical(price(t.ceded[0], TAIL, cost_of_capital=RETURN), expenses=0.05, brokerage=0.10,
                        limit=float(limit))
    xl_quotes[xl.name] = (q, t)
    record(xl.name, t.ceded[0].mean(), q.premium, q.premium - t.ceded[0].mean(),
           GROSS_CAPITAL - cedant_capital(t.net))
structure_table(list(ROWS), "Excess of loss: which attachment and limit?")
```


<style>
#abihvujniy 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;
        }

#abihvujniy thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#abihvujniy p { margin: 0; padding: 0; }
 #abihvujniy .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; }
 #abihvujniy .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #abihvujniy .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; }
 #abihvujniy .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; }
 #abihvujniy .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; }
 #abihvujniy .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #abihvujniy .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; }
 #abihvujniy .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; }
 #abihvujniy .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; }
 #abihvujniy .gt_column_spanner_outer:first-child { padding-left: 0; }
 #abihvujniy .gt_column_spanner_outer:last-child { padding-right: 0; }
 #abihvujniy .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%; }
 #abihvujniy .gt_spanner_row { border-bottom-style: hidden; }
 #abihvujniy .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; }
 #abihvujniy .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; }
 #abihvujniy .gt_from_md> :first-child { margin-top: 0; }
 #abihvujniy .gt_from_md> :last-child { margin-bottom: 0; }
 #abihvujniy .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; }
 #abihvujniy .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; }
 #abihvujniy .gt_indent_1 { text-indent: 5px; }
 #abihvujniy .gt_indent_2 { text-indent: calc(5px * 2); }
 #abihvujniy .gt_indent_3 { text-indent: calc(5px * 3); }
 #abihvujniy .gt_indent_4 { text-indent: calc(5px * 4); }
 #abihvujniy .gt_indent_5 { text-indent: calc(5px * 5); }
 #abihvujniy .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; }
 #abihvujniy .gt_row_group_first td { border-top-width: 2px; }
 #abihvujniy .gt_row_group_first th { border-top-width: 2px; }
 #abihvujniy .gt_striped { color: #333333; background-color: #F4F4F4; }
 #abihvujniy .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; }
 #abihvujniy .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #abihvujniy .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #abihvujniy .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #abihvujniy .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #abihvujniy .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #abihvujniy .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #abihvujniy .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; }
 #abihvujniy .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #abihvujniy .gt_left { text-align: left; }
 #abihvujniy .gt_center { text-align: center; }
 #abihvujniy .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #abihvujniy .gt_font_normal { font-weight: normal; }
 #abihvujniy .gt_font_bold { font-weight: bold; }
 #abihvujniy .gt_font_italic { font-style: italic; }
 #abihvujniy .gt_super { font-size: 65%; }
 #abihvujniy .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; }
 #abihvujniy .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #abihvujniy .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; }
 #abihvujniy .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #abihvujniy .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #abihvujniy .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="7" id="title" class="gt_heading gt_title gt_font_normal">Excess of loss: which attachment and limit?</th>
</tr>
<tr class="gt_heading">
<th colspan="7" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions; value = 16% of the capital saved, minus the cost</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="ceded" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">ceded</th>
<th id="premium" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">premium</th>
<th id="cost" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">cost</th>
<th id="saved" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">saved</th>
<th id="cost-2" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">cost %</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">XL 23x2</th>
<td class="gt_row gt_right" headers="stub-1 ceded">20.91</td>
<td class="gt_row gt_right" headers="stub-1 premium">30.52</td>
<td class="gt_row gt_right" headers="stub-1 cost">9.61</td>
<td class="gt_row gt_right" headers="stub-1 saved">42.89</td>
<td class="gt_row gt_right" headers="stub-1 cost-2">22.4%</td>
<td class="gt_row gt_right" headers="stub-1 value">−2.75</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">XL 20x5</th>
<td class="gt_row gt_right" headers="stub-2 ceded">10.67</td>
<td class="gt_row gt_right" headers="stub-2 premium">17.26</td>
<td class="gt_row gt_right" headers="stub-2 cost">6.59</td>
<td class="gt_row gt_right" headers="stub-2 saved">29.73</td>
<td class="gt_row gt_right" headers="stub-2 cost-2">22.2%</td>
<td class="gt_row gt_right" headers="stub-2 value">−1.84</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">XL 10x5</th>
<td class="gt_row gt_right" headers="stub-3 ceded">8.46</td>
<td class="gt_row gt_right" headers="stub-3 premium">13.07</td>
<td class="gt_row gt_right" headers="stub-3 cost">4.61</td>
<td class="gt_row gt_right" headers="stub-3 saved">22.64</td>
<td class="gt_row gt_right" headers="stub-3 cost-2">20.3%</td>
<td class="gt_row gt_right" headers="stub-3 value">−0.98</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">XL 15x10</th>
<td class="gt_row gt_right" headers="stub-4 ceded">4.72</td>
<td class="gt_row gt_right" headers="stub-4 premium">8.76</td>
<td class="gt_row gt_right" headers="stub-4 cost">4.03</td>
<td class="gt_row gt_right" headers="stub-4 saved">17.88</td>
<td class="gt_row gt_right" headers="stub-4 cost-2">22.6%</td>
<td class="gt_row gt_right" headers="stub-4 value">−1.17</td>
</tr>
</tbody>
</table>


A lower attachment saves more capital, but costs more. Each layer costs 20% to 23% of the capital that it releases, above the 16% of the cedant. The 10x5 layer has the best value, still negative.


### Quota share with a sliding-scale commission

A quota share cedes a fixed share of each claim and of the premium, here 25%. The reinsurer pays a **ceding commission** for the expenses of the cedant. The technical commission is the ceded premium left after the risk premium of the reinsurer, 2% expenses and 1.5% brokerage ([section 4 of the price guide](reinsurance-price.md#4-quota-share)).

A **sliding scale** pays more commission when the ceded loss ratio is low, and less when it is high. Here the scale has the same expected commission as the flat commission.


``` python
CESSION = 0.25
ceded_premium = CESSION * PREMIUM
qs = Layer.quota_share("QS 25%", CESSION).with_premium_rate(1.0, PREMIUM)
ceded = Tower([qs]).on_grid(frequency, claims, POINTS).ceded[0]
risk_premium = price(ceded, TAIL, cost_of_capital=RETURN).premium
technical = 1 - risk_premium / ceded_premium - 0.02 - 0.015    # less the reinsurer's expenses and brokerage
flat = qs.with_ceding_commission(technical)

shape = [(0.40, 0.45), (0.25, 0.65)]   # (commission, loss ratio): 40% at 45% or less, 25% at 65% or more
expected = Tower([qs.with_sliding_scale(shape)]).on_grid(frequency, claims, POINTS).expected_ceding_commission[0]
shift = technical - expected / ceded_premium
slide = qs.with_sliding_scale([(c + shift, lr) for c, lr in shape])
print(f"technical commission {technical:.1%}; the scale runs from {shape[0][0] + shift:.1%} to {shape[1][0] + shift:.1%}")
for layer in (flat, slide):
    result = [(ceded_premium - layer.ceding_commission_for(CESSION * x) - CESSION * x, p)
              for x, p in ((i * gross.step, p) for i, p in enumerate(gross.probs))]
    mean = sum(r * p for r, p in result)
    sd = math.sqrt(sum((r - mean) ** 2 * p for r, p in result))
    print(f"reinsurer, {'flat' if layer is flat else 'sliding':<7}: expected result {mean:.2f}, sd {sd:.2f}")
```


    technical commission 41.0%; the scale runs from 46.2% to 31.2%
    reinsurer, flat   : expected result 2.44, sd 4.98
    reinsurer, sliding: expected result 2.44, sd 3.66


``` python
ratios = [0.4, 0.5, 0.6, 0.7, 0.8]
scale_t = pd.DataFrame({"loss ratio": [f"{lr:.0%}" for lr in ratios],
                        "flat": [flat.ceding_commission_for(lr * ceded_premium) / ceded_premium for lr in ratios],
                        "sliding": [slide.ceding_commission_for(lr * ceded_premium) / ceded_premium for lr in ratios]})
(GT(scale_t, rowname_col="loss ratio")
 .tab_header("Ceding commission by ceded loss ratio", "Share of the ceded premium")
 .fmt_percent(["flat", "sliding"], decimals=1))
```


<style>
#klbtvzlmnq 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;
        }

#klbtvzlmnq thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#klbtvzlmnq p { margin: 0; padding: 0; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_column_spanner_outer:first-child { padding-left: 0; }
 #klbtvzlmnq .gt_column_spanner_outer:last-child { padding-right: 0; }
 #klbtvzlmnq .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%; }
 #klbtvzlmnq .gt_spanner_row { border-bottom-style: hidden; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_from_md> :first-child { margin-top: 0; }
 #klbtvzlmnq .gt_from_md> :last-child { margin-bottom: 0; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_indent_1 { text-indent: 5px; }
 #klbtvzlmnq .gt_indent_2 { text-indent: calc(5px * 2); }
 #klbtvzlmnq .gt_indent_3 { text-indent: calc(5px * 3); }
 #klbtvzlmnq .gt_indent_4 { text-indent: calc(5px * 4); }
 #klbtvzlmnq .gt_indent_5 { text-indent: calc(5px * 5); }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_row_group_first td { border-top-width: 2px; }
 #klbtvzlmnq .gt_row_group_first th { border-top-width: 2px; }
 #klbtvzlmnq .gt_striped { color: #333333; background-color: #F4F4F4; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #klbtvzlmnq .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #klbtvzlmnq .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #klbtvzlmnq .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #klbtvzlmnq .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #klbtvzlmnq .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #klbtvzlmnq .gt_left { text-align: left; }
 #klbtvzlmnq .gt_center { text-align: center; }
 #klbtvzlmnq .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #klbtvzlmnq .gt_font_normal { font-weight: normal; }
 #klbtvzlmnq .gt_font_bold { font-weight: bold; }
 #klbtvzlmnq .gt_font_italic { font-style: italic; }
 #klbtvzlmnq .gt_super { font-size: 65%; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #klbtvzlmnq .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; }
 #klbtvzlmnq .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #klbtvzlmnq .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #klbtvzlmnq .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">Ceding commission by ceded loss ratio</th>
</tr>
<tr class="gt_heading">
<th colspan="3" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Share of the ceded premium</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="flat" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">flat</th>
<th id="sliding" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">sliding</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">40%</th>
<td class="gt_row gt_right" headers="stub-1 flat">41.0%</td>
<td class="gt_row gt_right" headers="stub-1 sliding">46.2%</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">50%</th>
<td class="gt_row gt_right" headers="stub-2 flat">41.0%</td>
<td class="gt_row gt_right" headers="stub-2 sliding">42.5%</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">60%</th>
<td class="gt_row gt_right" headers="stub-3 flat">41.0%</td>
<td class="gt_row gt_right" headers="stub-3 sliding">35.0%</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">70%</th>
<td class="gt_row gt_right" headers="stub-4 flat">41.0%</td>
<td class="gt_row gt_right" headers="stub-4 sliding">31.2%</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">80%</th>
<td class="gt_row gt_right" headers="stub-5 flat">41.0%</td>
<td class="gt_row gt_right" headers="stub-5 sliding">31.2%</td>
</tr>
</tbody>
</table>


The sliding commission falls from 46.2% to 31.2% as the loss ratio rises from 45% to 65%. The expected result of the reinsurer is 2.44 for both commissions, but its standard deviation falls from 4.98 to 3.66: in a bad year it pays less commission, so the cedant takes back a part of the bad years. [The sliding scales of the price guide](reinsurance-price.md#sliding-scales-and-profit-commissions) show how much more commission a reinsurer can give for that. `gross.map` turns each gross outcome into the cost of the cedant in that outcome:


``` python
for label, layer in [("QS 25% flat", flat), ("QS 25% slide", slide)]:
    net_cost, _ = gross.map(lambda x: (1 - CESSION) * x + ceded_premium - layer.ceding_commission_for(CESSION * x))
    record(label, ceded.mean(), ceded_premium * (1 - technical), net_cost.mean() - gross.mean(),
           GROSS_CAPITAL - cedant_capital(net_cost))
structure_table(["QS 25% flat", "QS 25% slide"], "Quota share, flat and sliding commission")
```


<style>
#cvmqnfhiti 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;
        }

#cvmqnfhiti thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#cvmqnfhiti p { margin: 0; padding: 0; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_column_spanner_outer:first-child { padding-left: 0; }
 #cvmqnfhiti .gt_column_spanner_outer:last-child { padding-right: 0; }
 #cvmqnfhiti .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%; }
 #cvmqnfhiti .gt_spanner_row { border-bottom-style: hidden; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_from_md> :first-child { margin-top: 0; }
 #cvmqnfhiti .gt_from_md> :last-child { margin-bottom: 0; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_indent_1 { text-indent: 5px; }
 #cvmqnfhiti .gt_indent_2 { text-indent: calc(5px * 2); }
 #cvmqnfhiti .gt_indent_3 { text-indent: calc(5px * 3); }
 #cvmqnfhiti .gt_indent_4 { text-indent: calc(5px * 4); }
 #cvmqnfhiti .gt_indent_5 { text-indent: calc(5px * 5); }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_row_group_first td { border-top-width: 2px; }
 #cvmqnfhiti .gt_row_group_first th { border-top-width: 2px; }
 #cvmqnfhiti .gt_striped { color: #333333; background-color: #F4F4F4; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #cvmqnfhiti .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #cvmqnfhiti .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #cvmqnfhiti .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #cvmqnfhiti .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #cvmqnfhiti .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #cvmqnfhiti .gt_left { text-align: left; }
 #cvmqnfhiti .gt_center { text-align: center; }
 #cvmqnfhiti .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #cvmqnfhiti .gt_font_normal { font-weight: normal; }
 #cvmqnfhiti .gt_font_bold { font-weight: bold; }
 #cvmqnfhiti .gt_font_italic { font-style: italic; }
 #cvmqnfhiti .gt_super { font-size: 65%; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #cvmqnfhiti .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; }
 #cvmqnfhiti .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #cvmqnfhiti .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #cvmqnfhiti .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="7" id="title" class="gt_heading gt_title gt_font_normal">Quota share, flat and sliding commission</th>
</tr>
<tr class="gt_heading">
<th colspan="7" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions; value = 16% of the capital saved, minus the cost</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="ceded" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">ceded</th>
<th id="premium" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">premium</th>
<th id="cost" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">cost</th>
<th id="saved" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">saved</th>
<th id="cost-2" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">cost %</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">QS 25% flat</th>
<td class="gt_row gt_right" headers="stub-1 ceded">12.32</td>
<td class="gt_row gt_right" headers="stub-1 premium">14.76</td>
<td class="gt_row gt_right" headers="stub-1 cost">2.44</td>
<td class="gt_row gt_right" headers="stub-1 saved">16.34</td>
<td class="gt_row gt_right" headers="stub-1 cost-2">14.9%</td>
<td class="gt_row gt_right" headers="stub-1 value">0.18</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">QS 25% slide</th>
<td class="gt_row gt_right" headers="stub-2 ceded">12.32</td>
<td class="gt_row gt_right" headers="stub-2 premium">14.76</td>
<td class="gt_row gt_right" headers="stub-2 cost">2.44</td>
<td class="gt_row gt_right" headers="stub-2 saved">13.94</td>
<td class="gt_row gt_right" headers="stub-2 cost-2">17.5%</td>
<td class="gt_row gt_right" headers="stub-2 value">−0.21</td>
</tr>
</tbody>
</table>


Here "premium" is the ceded premium minus the expected commission, and the cost is the expected result of the reinsurer for both commissions. The flat commission releases 16.34 of capital, the scale only 13.94: under the scale, the cedant still pays for its bad years through a lower commission.


### Reinstatements

A real excess of loss layer limits how often it pays in a year. With one **reinstatement**, the 10x5 layer pays a maximum of 20 a year. A **paid** reinstatement charges extra premium when a loss uses the limit, so a part of the price comes after the losses. Annual terms need the claims year by year, so this block simulates 10,000 years.

Both versions have the expected premium of the 10x5 technical premium above. When the reinstatement is free, all of it is deposit. When it is paid at 100%, the deposit is smaller and the expected reinstatement premium supplies the rest.


``` python
events = simulate_events(frequency, claims, N, 7)
technical_xl = xl_quotes["XL 10x5"][0].premium


def cedant_cost(deposit, rates):
    """Gross and the cedant's cost (net loss, deposit and reinstatement premium) in each simulated year."""
    years = Tower([Layer("10x5", 10.0, 5.0, premium=deposit, reinstatement_rates=rates)]).apply(events).draw_matrix()
    # the columns: gross, ceded, net, reinstatement premium
    gross_years = Sampled([g for g, _, _, _ in years])
    cost_years = Sampled([net + deposit + rp for _, _, net, rp in years])
    return gross_years, cost_years, sum(rp for *_, rp in years) / len(years)


_, _, rp = cedant_cost(technical_xl, [1.0])
paid_deposit = technical_xl / (1 + rp / technical_xl)   # the same expected premium, part paid after losses
reinstated = []
for label, deposit, rates in [("free", technical_xl, [0.0]), ("paid at 100%", paid_deposit, [1.0])]:
    gross_years, cost_years, rp = cedant_cost(deposit, rates)
    saved = cedant_capital(gross_years) - cedant_capital(cost_years)
    reinstated.append((label, deposit, rp, saved))
(GT(pd.DataFrame(reinstated, columns=["reinstatement", "deposit", "expected reinstatement premium", "capital saved"]),
    rowname_col="reinstatement")
 .tab_header("The 10x5 layer with one reinstatement", "Millions; the same expected premium in both rows")
 .fmt_number(["deposit", "expected reinstatement premium", "capital saved"], decimals=2))
```


<style>
#avqacpjzjb 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;
        }

#avqacpjzjb thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#avqacpjzjb p { margin: 0; padding: 0; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #avqacpjzjb .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; }
 #avqacpjzjb .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; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #avqacpjzjb .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; }
 #avqacpjzjb .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; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_column_spanner_outer:first-child { padding-left: 0; }
 #avqacpjzjb .gt_column_spanner_outer:last-child { padding-right: 0; }
 #avqacpjzjb .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%; }
 #avqacpjzjb .gt_spanner_row { border-bottom-style: hidden; }
 #avqacpjzjb .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; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_from_md> :first-child { margin-top: 0; }
 #avqacpjzjb .gt_from_md> :last-child { margin-bottom: 0; }
 #avqacpjzjb .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; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_indent_1 { text-indent: 5px; }
 #avqacpjzjb .gt_indent_2 { text-indent: calc(5px * 2); }
 #avqacpjzjb .gt_indent_3 { text-indent: calc(5px * 3); }
 #avqacpjzjb .gt_indent_4 { text-indent: calc(5px * 4); }
 #avqacpjzjb .gt_indent_5 { text-indent: calc(5px * 5); }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_row_group_first td { border-top-width: 2px; }
 #avqacpjzjb .gt_row_group_first th { border-top-width: 2px; }
 #avqacpjzjb .gt_striped { color: #333333; background-color: #F4F4F4; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #avqacpjzjb .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #avqacpjzjb .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #avqacpjzjb .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #avqacpjzjb .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #avqacpjzjb .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #avqacpjzjb .gt_left { text-align: left; }
 #avqacpjzjb .gt_center { text-align: center; }
 #avqacpjzjb .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #avqacpjzjb .gt_font_normal { font-weight: normal; }
 #avqacpjzjb .gt_font_bold { font-weight: bold; }
 #avqacpjzjb .gt_font_italic { font-style: italic; }
 #avqacpjzjb .gt_super { font-size: 65%; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #avqacpjzjb .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; }
 #avqacpjzjb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #avqacpjzjb .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #avqacpjzjb .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">The 10x5 layer with one reinstatement</th>
</tr>
<tr class="gt_heading">
<th colspan="4" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions; the same expected premium in both rows</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="deposit" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">deposit</th>
<th id="expected-reinstatement-premium" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">expected reinstatement premium</th>
<th id="capital-saved" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">capital saved</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">free</th>
<td class="gt_row gt_right" headers="stub-1 deposit">13.07</td>
<td class="gt_row gt_right" headers="stub-1 expected-reinstatement-premium">0.00</td>
<td class="gt_row gt_right" headers="stub-1 capital-saved">12.06</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">paid at 100%</th>
<td class="gt_row gt_right" headers="stub-2 deposit">8.19</td>
<td class="gt_row gt_right" headers="stub-2 expected-reinstatement-premium">4.88</td>
<td class="gt_row gt_right" headers="stub-2 capital-saved">8.74</td>
</tr>
</tbody>
</table>


Without an annual limit, the layer saves about 22 of capital (22.64 on the grid, 22.26 on these simulated years). The annual limit cuts this to 12.06, because the losses of the layer exceed 20 in the worst years. A paid reinstatement cuts it to 8.74: the cedant pays the reinstatement premium in the same years that it wants protection.

The two rows compare only the two versions. A layer with an annual limit pays less than the unlimited 10x5, so its price is lower, and the decision table below omits them. [The reinstatements section of the price guide](reinsurance-price.md#reinstatements) prices them.


### The decision

The structures in order of value, best first:


``` python
order = sorted(ROWS, key=lambda k: HURDLE * ROWS[k]["saved"] - ROWS[k]["cost"], reverse=True)
structure_table(order, "The six structures in order of value", drop=("ceded", "premium"))
```


<style>
#vlyznuvyzp 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;
        }

#vlyznuvyzp thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#vlyznuvyzp p { margin: 0; padding: 0; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_column_spanner_outer:first-child { padding-left: 0; }
 #vlyznuvyzp .gt_column_spanner_outer:last-child { padding-right: 0; }
 #vlyznuvyzp .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%; }
 #vlyznuvyzp .gt_spanner_row { border-bottom-style: hidden; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_from_md> :first-child { margin-top: 0; }
 #vlyznuvyzp .gt_from_md> :last-child { margin-bottom: 0; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_indent_1 { text-indent: 5px; }
 #vlyznuvyzp .gt_indent_2 { text-indent: calc(5px * 2); }
 #vlyznuvyzp .gt_indent_3 { text-indent: calc(5px * 3); }
 #vlyznuvyzp .gt_indent_4 { text-indent: calc(5px * 4); }
 #vlyznuvyzp .gt_indent_5 { text-indent: calc(5px * 5); }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_row_group_first td { border-top-width: 2px; }
 #vlyznuvyzp .gt_row_group_first th { border-top-width: 2px; }
 #vlyznuvyzp .gt_striped { color: #333333; background-color: #F4F4F4; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #vlyznuvyzp .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #vlyznuvyzp .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #vlyznuvyzp .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #vlyznuvyzp .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #vlyznuvyzp .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #vlyznuvyzp .gt_left { text-align: left; }
 #vlyznuvyzp .gt_center { text-align: center; }
 #vlyznuvyzp .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #vlyznuvyzp .gt_font_normal { font-weight: normal; }
 #vlyznuvyzp .gt_font_bold { font-weight: bold; }
 #vlyznuvyzp .gt_font_italic { font-style: italic; }
 #vlyznuvyzp .gt_super { font-size: 65%; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #vlyznuvyzp .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; }
 #vlyznuvyzp .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #vlyznuvyzp .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #vlyznuvyzp .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 six structures in order of value</th>
</tr>
<tr class="gt_heading">
<th colspan="5" id="subtitle" class="gt_heading gt_subtitle gt_font_normal gt_bottom_border">Millions; value = 16% of the capital saved, minus the cost</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="cost" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">cost</th>
<th id="saved" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">saved</th>
<th id="cost-2" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">cost %</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">QS 25% flat</th>
<td class="gt_row gt_right" headers="stub-1 cost">2.44</td>
<td class="gt_row gt_right" headers="stub-1 saved">16.34</td>
<td class="gt_row gt_right" headers="stub-1 cost-2">14.9%</td>
<td class="gt_row gt_right" headers="stub-1 value">0.18</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">QS 25% slide</th>
<td class="gt_row gt_right" headers="stub-2 cost">2.44</td>
<td class="gt_row gt_right" headers="stub-2 saved">13.94</td>
<td class="gt_row gt_right" headers="stub-2 cost-2">17.5%</td>
<td class="gt_row gt_right" headers="stub-2 value">−0.21</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">XL 10x5</th>
<td class="gt_row gt_right" headers="stub-3 cost">4.61</td>
<td class="gt_row gt_right" headers="stub-3 saved">22.64</td>
<td class="gt_row gt_right" headers="stub-3 cost-2">20.3%</td>
<td class="gt_row gt_right" headers="stub-3 value">−0.98</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">XL 15x10</th>
<td class="gt_row gt_right" headers="stub-4 cost">4.03</td>
<td class="gt_row gt_right" headers="stub-4 saved">17.88</td>
<td class="gt_row gt_right" headers="stub-4 cost-2">22.6%</td>
<td class="gt_row gt_right" headers="stub-4 value">−1.17</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">XL 20x5</th>
<td class="gt_row gt_right" headers="stub-5 cost">6.59</td>
<td class="gt_row gt_right" headers="stub-5 saved">29.73</td>
<td class="gt_row gt_right" headers="stub-5 cost-2">22.2%</td>
<td class="gt_row gt_right" headers="stub-5 value">−1.84</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">XL 23x2</th>
<td class="gt_row gt_right" headers="stub-6 cost">9.61</td>
<td class="gt_row gt_right" headers="stub-6 saved">42.89</td>
<td class="gt_row gt_right" headers="stub-6 cost-2">22.4%</td>
<td class="gt_row gt_right" headers="stub-6 value">−2.75</td>
</tr>
</tbody>
</table>


The last line reprices 10x5 with the loads of the quota share (2% expenses and 1.5% brokerage, not 15%) to show how much of the difference they explain.


``` python
print(f"buy: {order[0]}")
q, t = xl_quotes["XL 10x5"]
cheap = Quote.technical(price(t.ceded[0], TAIL, cost_of_capital=RETURN), expenses=0.02, brokerage=0.015, limit=10.0)
cost, saved = cheap.premium - t.ceded[0].mean(), ROWS["XL 10x5"]["saved"]
print(f"XL 10x5 at the quota share's loads: premium {cheap.premium:.2f}, cost {cost:.2f}, "
      f"value {HURDLE * saved - cost:.2f}")
```


    buy: QS 25% flat
    XL 10x5 at the quota share's loads: premium 11.51, cost 3.05, value 0.57


With these inputs, the cedant should buy the 25% quota share at a flat commission. It is the only structure that releases capital for less than the 16% that the owners charge. The sliding scale gives back a part of that relief.

Most of the difference from the excess of loss layers is the frictional load: the layers carry 15% for expenses and brokerage, the quota share 3.5%. At the loads of the quota share, 10x5 has a value of 0.57, the best of all. The decision depends on the real charge of the excess of loss market. Get a firm quote for 10x5 before you sign the quota share.

A higher cost of capital for the cedant, or a TVaR standard that weights the tail more, favours the excess of loss. Repeat the comparison with your own numbers. Do not reuse this result for another cedant. [What the reinsurer decides](reinsurance-price.md#8-what-the-reinsurer-decides) shows the other side.


# Part 3. The checklist


## 10. Ten steps from data to a quote

| Step | Call | Check | Usual mistake |
|----|----|----|----|
| 1\. Premium at today's rate level, losses trended | [RateHistory](../reference/pricing.RateHistory.md#prospicio.pricing.RateHistory), [Period](../reference/pricing.Period.md#prospicio.pricing.Period), [TrendFit](../reference/pricing.TrendFit.md#prospicio.pricing.TrendFit), [trend_factor](../reference/pricing.trend_factor.md#prospicio.pricing.trend_factor) | On-level factors decrease toward recent years | Trending premium and losses with the same factor, or forgetting the rate changes |
| 2\. Develop losses to ultimate | [Triangle](../reference/reserving.Triangle.md#prospicio.reserving.Triangle), [ChainLadder](../reference/reserving.ChainLadder.md#prospicio.reserving.ChainLadder). For large losses: [DevelopmentPattern.from_history](../reference/pricing.DevelopmentPattern.md#prospicio.pricing.DevelopmentPattern.from_history), [LargeLossExperience](../reference/pricing.LargeLossExperience.md#prospicio.pricing.LargeLossExperience) | Compare with [BornhuetterFerguson](../reference/reserving.BornhuetterFerguson.md#prospicio.reserving.BornhuetterFerguson) on the youngest years | Developing a layer with ground-up factors (use [ExcessPattern](../reference/reserving.ExcessPattern.md#prospicio.reserving.ExcessPattern)) |
| 3\. Severity and frequency | `fit_severity`, `goodness_of_fit`, [Poisson](../reference/distributions.Poisson.md#prospicio.distributions.Poisson), [NegativeBinomial](../reference/distributions.NegativeBinomial.md#prospicio.distributions.NegativeBinomial), [Truncated](../reference/distributions.Truncated.md#prospicio.distributions.Truncated) | Fit above the reporting threshold. Censor claims at their policy limit | A ground-up severity with a count of claims above the threshold, or a Poisson count when the variance is larger than the mean |
| 4\. Aggregate distribution | [fft](../reference/aggregate.fft.md#prospicio.aggregate.fft), [audit_grid](../reference/aggregate.audit_grid.md#prospicio.aggregate.audit_grid) | `report.aliasing_error`, `report.tail_mass` | A grid too short for the tail |
| 5\. Contract terms | [Layer](../reference/reinsurance.Layer.md#prospicio.reinsurance.Layer), [Tower](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower), then [on_grid](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.on_grid) or [apply](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.apply) | [on_points](../reference/reinsurance.TowerGrids.md#prospicio.reinsurance.TowerGrids.on_points) | Annual terms (reinstatements, aggregate limits) on the grid. Then [net](../reference/reinsurance.TowerGrids.md#prospicio.reinsurance.TowerGrids.net) is `None`, so simulate and use [apply](../reference/reinsurance.Tower.md#prospicio.reinsurance.Tower.apply) |
| 6\. Expected loss two ways, blended | Experience: [PreparedLosses.burning_cost](../reference/pricing.PreparedLosses.md#prospicio.pricing.PreparedLosses.burning_cost). Exposure: [RiskProfile](../reference/pricing.RiskProfile.md#prospicio.pricing.RiskProfile), [Mbbefd](../reference/pricing.Mbbefd.md#prospicio.pricing.Mbbefd). Blend: [LimitedFluctuation](../reference/credibility.LimitedFluctuation.md#prospicio.credibility.LimitedFluctuation), [credibility_weighted](../reference/pricing.credibility_weighted.md#prospicio.pricing.credibility_weighted) | The two estimates are in a plausible range of each other | Full credibility for a layer with a small number of claims |
| 7\. Capital standard | [Distortion.tvar](../reference/risk.Distortion.md#prospicio.risk.Distortion.tvar), [Portfolio.assets](../reference/pricing.Portfolio.md#prospicio.pricing.Portfolio.assets), [Portfolio.assets_for_epd](../reference/pricing.Portfolio.md#prospicio.pricing.Portfolio.assets_for_epd) | The same standard for all options that you compare | Comparing one option on VaR with another on TVaR |
| 8\. Distortion calibrated | [Portfolio.calibrate](../reference/pricing.Portfolio.md#prospicio.pricing.Portfolio.calibrate), [calibrate](../reference/risk.calibrate.md#prospicio.risk.calibrate) | The calibrated book earns its target return | Calibrating to a premium on uncapped losses, then pricing with capped assets |
| 9\. Allocation | [Portfolio.price](../reference/pricing.Portfolio.md#prospicio.pricing.Portfolio.price), [capital](../reference/risk.capital.md#prospicio.risk.capital) | Allocations add up to the total of the book | Comparing returns by line under different methods |
| 10\. Quote and sensitivity | [Quote.technical](../reference/pricing.Quote.md#prospicio.pricing.Quote.technical), [Quote.at](../reference/pricing.Quote.md#prospicio.pricing.Quote.at) | Rate on line and return at the market price | Quoting the technical premium without a comparison with the market rate on line for similar layers |

[The submission evaluation notebook](submission_evaluation.md) runs these steps on a synthetic submission.

The template below runs the ten steps for one excess of loss layer. It needs two files of your own:

- `my_premium.csv`, one row for each accident year: `year`, `earned_premium`.
- `my_losses.csv`, one row for each claim and development age: `claim_id`, `accident_year`, [development](../reference/reserving.MackFit.md#prospicio.reserving.MackFit.development) (in months: 12, 24, …) and `incurred` (cumulative). List each claim at each age up to the latest. When a value did not change, repeat it. If you do not, the summed triangle is wrong.

Change each value marked "yours" and check the output of each step. The tests do not run the template.


``` python
import csv
from statistics import mean, variance

from prospicio.aggregate import audit_grid, fft
from prospicio.credibility import LimitedFluctuation
from prospicio.distributions import Grid, NegativeBinomial, Truncated, fit_severity, goodness_of_fit
from prospicio.pricing import DevelopmentPattern, LargeLossExperience, Period, Quote, RateHistory, credibility_weighted, price
from prospicio.reinsurance import Layer, Tower
from prospicio.reserving import ChainLadder, Triangle
from prospicio.risk import Distortion

VALUATION, FUTURE, LOSS_TREND = 2026.0, 2027.5, 0.05      # yours: valuation date, mid-point of the period priced, trend
FUTURE_PREMIUM = 120.0                                    # yours: subject premium of the period priced
THRESHOLD, POLICY_LIMIT = 1.0, 25.0                       # yours: reporting threshold of large claims, policy limit
ATTACHMENT, LIMIT = 5.0, 10.0                             # the layer priced
COUNT_IBNR = {}                                           # yours: large-claim count development factor by year (default 1)
premium = {int(r["year"]): float(r["earned_premium"]) for r in csv.DictReader(open("my_premium.csv"))}
rows = list(csv.DictReader(open("my_losses.csv")))
years = sorted(premium)

# 1. Premium at today's rate level (the losses are trended in step 2)
history = RateHistory([2023.0, 2025.0], [0.05, 0.03])    # yours: effective dates and rate changes
on_level = [premium[y] * history.rate_level(Period.calendar(y, y + 1), 1.0).on_level_factor for y in years]

# 2. Develop to ultimate: the ground-up triangle, and each large claim's IBNER from the claims' own histories
tri = Triangle.from_long([int(r["accident_year"]) for r in rows], [int(r["development"]) for r in rows],
                         {"incurred": [float(r["incurred"]) for r in rows]})
cl = ChainLadder().fit(tri, "incurred")
print("ultimate loss ratios:", [round(u / p, 3) for u, p in zip(cl.ultimate, on_level)])
age = [int(r["development"]) / 12 - 0.5 for r in rows]                         # years since a mid-year accident
ibner = DevelopmentPattern.from_history([r["claim_id"] for r in rows], age,
                                        [float(r["incurred"]) for r in rows], ages=sorted(set(age)))
latest = {r["claim_id"]: r for r in sorted(rows, key=lambda r: int(r["development"]))}
ids = list(latest)
record = LargeLossExperience(ids, [int(latest[i]["accident_year"]) + 0.5 for i in ids],
                             [float(latest[i]["incurred"]) for i in ids], threshold=THRESHOLD, valuation=VALUATION)
prepared = record.prepare(rate=LOSS_TREND, to=FUTURE, development=ibner)   # developed (IBNER) and trended
floor = prepared.complete_above                           # every year is complete above this trended size

# 3. Severity of the large claims above the floor, and their yearly count at next year's premium
large = [(int(latest[i]["accident_year"]), x, float(latest[i]["incurred"]) >= POLICY_LIMIT)
         for i, x in zip(ids, prepared.trended) if x > floor]
sizes = [x for _, x, _ in large]
capped = [c for _, _, c in large]                         # censored: a policy limit capped the loss
fit = fit_severity("lognormal", sizes, reporting_thresholds=[floor] * len(sizes), censored=capped)
gof = goodness_of_fit(fit.distribution, sizes, reporting_thresholds=[floor] * len(sizes), censored=capped)
print(fit.parameters, "largest gap to the data:", round(gof["max_distance"], 3))
counts = [FUTURE_PREMIUM * COUNT_IBNR.get(y, 1.0) * sum(v == y for v, _, _ in large) / p for y, p in zip(years, on_level)]
frequency = NegativeBinomial.from_mean_variance(mean(counts), max(variance(counts), 1.01 * mean(counts)))
severity = Truncated(fit.distribution, lower=floor)       # the fit is ground up; the count is of claims above the floor

# 4. Aggregate distribution, with the grid chosen and checked
audit = audit_grid(frequency, severity)
claims, _ = Grid.rounding(severity, audit.step, round(POLICY_LIMIT / audit.step) + 1)   # capped at the policy limit
_, report = fft(frequency, claims, 2**audit.log2)
assert report.aliasing_error < 1e-6 and report.tail_mass < 1e-6, "use more points or a larger step"

# 5. Contract terms
tower = Tower([Layer("layer", LIMIT, ATTACHMENT)])
layer_loss = tower.on_grid(frequency, claims, 2**audit.log2).ceded[0]

# 6. Expected loss two ways, blended by credibility
burn = prepared.burning_cost(tower, years, premium=on_level, development=[COUNT_IBNR.get(y, 1.0) for y in years])
experience = burn.loss_cost[0] * FUTURE_PREMIUM          # the layer's loss cost on on-level premium, at next year's premium
exposure = layer_loss.mean()                              # yours: a stand-in; use a RiskProfile or an exposure curve
lf = LimitedFluctuation(0.90, 0.05)
z = lf.credibility(sum(x > ATTACHMENT for x in sizes), lf.frequency_standard())
blended = credibility_weighted(experience, z, exposure)
print(f"experience {experience:.3f}, exposure {exposure:.3f}, credibility {z:.2f}, blended {blended:.3f}")

# 7 to 9. Capital standard and price of risk (for a book: Portfolio.calibrate and Portfolio.price, section 8)
TAIL = Distortion.tvar(0.99)
risk = price(layer_loss, TAIL, cost_of_capital=0.10)
scale = blended / layer_loss.mean()                       # moves the modelled layer loss to the blended estimate

# 10. Quote and sensitivity. Scaling loss, premium and assets together leaves every return unchanged.
quote = Quote.technical(risk, expenses=0.05, brokerage=0.10, limit=LIMIT)
print(f"technical premium {quote.premium * scale:.3f}, rate on line {quote.premium * scale / LIMIT:.1%}")
for market in (0.8, 1.0, 1.2):
    print(f"at {market:.0%} of technical: return on capital {quote.at(market * quote.premium).return_on_capital:.1%}")
```


Replace these three simplifications in the template:

1.  The exposure estimate is the same model that the experience fits, so the credibility blend has nothing independent to blend. Use an exposure rating instead: a [RiskProfile](../reference/pricing.RiskProfile.md#prospicio.pricing.RiskProfile) with an exposure curve, as in [that guide](experience-and-exposure-rating.md).
2.  The count development factors are 1 by default, correct only for mature years.
3.  The layer is developed with the IBNER of each claim, not with ground-up factors.


# Where to go next

- Steps 1 to 9: [the ratemaking guide](ratemaking-werner-modlin.md), [reserving methods](reserving-methods.md), [severity and frequency](severity-and-frequency.md), [aggregate distributions](aggregate-distributions.md) (when to use the FFT, Panjer's recursion, simulation or moments), [experience and exposure rating](experience-and-exposure-rating.md) and [risk loads and distortions](risk-loads-and-distortions.md) (also the families of distortions of section 5).
- [What a reinsurance price is](reinsurance-price.md): the full worked example behind sections 4 and 9, and the terms and the quote of steps 5 and 10.
- [Choosing a method](choosing-a-method.md): a decision table for the usual situations of an actuary.
- *Pricing Insurance Risk* reproduced: [risk measures](pir-risk-measures.md), [portfolio pricing](pir-portfolio-pricing.md) and [price allocation](pir-price-allocation.md).
- [Monograph 15's applications](capital-modeling-monograph-15-applications.md): new business, reinsurance and portfolio decisions on a full capital model.
- Notebooks: [the reading path](reading_path.md) and [a submission evaluation](submission_evaluation.md).


# Appendix: terms

- **Loss distribution**: what a cover can pay in a year, with the probability of each amount. Its **mean** is the expected loss. Its **coefficient of variation** (CV) is the standard deviation divided by the mean.
- **VaR** (value at risk) at 99%: the loss that only 1% of years exceed.
- **TVaR** (tail value at risk) at 99%: the average loss in the worst 1% of years. It is never smaller than the VaR.
- **Assets**: the money available to pay claims. A **capital standard** sets the amount, for example the 99% TVaR of the loss. In a year with a larger loss, the company defaults and the policyholders bear the rest (**limited liability**).
- **Premium** and **margin**: the premium pays part of the assets. The margin is the premium minus the expected loss, the reward of the owners.
- **Capital**: assets minus premium, supplied by the owners. **Cost of capital**: the return that the owners want on it, here 10% a year.
- **Distortion**: a rule that prices a loss. It gives bad outcomes more weight than their probability (section 5).
- **Allocation**: a split of the premium or capital of a book between its units.
- **Cedant**: an insurer that buys reinsurance.
- **Layer**: the part of each loss that an excess of loss contract pays, written limit x attachment (also called the retention). The layer 10x5 pays the part of each loss between 5 and 15.
- **Risk premium**: the expected loss plus the margin for capital. **Technical premium**: the risk premium plus expenses and brokerage. **Rate on line**: the premium of a layer divided by its limit.
- **On-level premium**: past premium at the rates of today. **IBNR**: claims incurred but not yet reported. A **censored** claim is capped by a policy limit: you know only that its true size is at least the cap.

[The glossary of the price guide](reinsurance-price.md#10-glossary-and-further-reading) has more reinsurance words.
