# Claim counts and aggregate claims: Bahnemann's *Distributions for Actuaries* reproduced

This guide recomputes the worked examples and problem answers of chapters 3 and 4 and section 6.4 of CAS Monograph 2, *Distributions for Actuaries* (David Bahnemann, 2015): counts, aggregate claims and aggregate limits. The [first guide](distributions-for-actuaries-claim-size.md) covers chapters 2, 5 and 6 and explains the conventions. Each table shows the monograph's printed value beside prospicio's. Read the monograph for the derivations.


# 1. Translating the parameters

The monograph writes the negative binomial with mean ν and gamma shape α (Var\[N\] = ν + ν²/α), later with the **contagion** γ = 1/α (Var\[N\] = ν + γν²). prospicio's `NegativeBinomial(r, beta)` has mean rβ and variance rβ(1 + β). `claim_count(mean, dispersion)` takes the variance-to-mean ratio:

| Monograph | prospicio |
|----|----|
| Poisson λ | `Poisson(λ)` |
| binomial (m, p) | `Binomial(m, p)` |
| negative binomial (α, ν) | `NegativeBinomial(r=α, beta=ν/α)` |
| negative binomial, mean ν and contagion γ | `claim_count(ν, 1 + γν)`, or `NegativeBinomial(1/γ, γν)` |
| Poisson mixed by a gamma with mean ν and shape α | `Count.mixed_poisson(ν, cv=1/√α, mixing="gamma")` |
| fitted by the method of moments | `NegativeBinomial.from_mean_variance(m, v)` |
| geometric with mean (1 − p)/p | `Count.geometric(mean)` |
| any count on 0, 1, 2, … | `Count.empirical(probs)` |


``` python
import math

import pandas as pd
from great_tables import GT

from prospicio.aggregate import compound_moments, fft, panjer, simulate_events
from prospicio.distributions import (
    Binomial, Count, Gamma, Grid, Lognormal, NegativeBinomial, Poisson, claim_count,
)


def compare(rows, title, subtitle=None):
    """Book against prospicio: rows of (label, book, prospicio) or (label, book, prospicio, decimals)."""
    frame = pd.DataFrame([(r[0], r[1], r[2], r[3] if len(r) > 3 else 4) for r in rows],
                         columns=["row", "book", "prospicio", "decimals"])
    table = GT(frame.drop(columns="decimals"), rowname_col="row").tab_header(title, subtitle)
    for places in sorted(set(frame["decimals"])):
        table = table.fmt_number(["book", "prospicio"],
                                 rows=list(frame.index[frame["decimals"] == places]), decimals=places)
    return table


def chi_square(observed, probs):
    n = sum(observed)
    return sum((o - n * p) ** 2 / (n * p) for o, p in zip(observed, probs))
```


# 2. The Poisson and the binomial

A Poisson count is the limit of a binomial with many trials and a small chance in each. Ex 3.1 counts days with a claim (0.3% a day). Ex 3.2 and P3.4 use annual rates of 0.04 and 0.10:


``` python
rows = [("Ex 3.1, 30 days, Pr{N = 0}", 0.9138, Binomial(30, 0.003).pmf(0)),
        ("Ex 3.1, 30 days, Pr{N = 1}", 0.0825, Binomial(30, 0.003).pmf(1)),
        ("Ex 3.1, 365 days, Pr{N = 2}", 0.2009, Binomial(365, 0.003).pmf(2))]
for t, book in [(1.0, (0.9608, 0.0384, 0.0008)), (1.5, (0.9418, 0.0565, 0.0017))]:
    for n in range(3):
        rows.append((f"Ex 3.2, {t} years, Pr{{N = {n}}}", book[n], Poisson(0.04 * t).pmf(n)))
for months, book in [(6, 0.0012), (15, 0.0069), (24, 0.0164)]:
    rows.append((f"P3.4, {months} months, Pr{{N = 2}}", book, Poisson(0.10 * months / 12).pmf(2)))
compare(rows, "Ex 3.1, Ex 3.2 and P3.4: binomial and Poisson probabilities")
```


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

#fuzngfwtrk thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#fuzngfwtrk p { margin: 0; padding: 0; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_column_spanner_outer:first-child { padding-left: 0; }
 #fuzngfwtrk .gt_column_spanner_outer:last-child { padding-right: 0; }
 #fuzngfwtrk .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%; }
 #fuzngfwtrk .gt_spanner_row { border-bottom-style: hidden; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_from_md> :first-child { margin-top: 0; }
 #fuzngfwtrk .gt_from_md> :last-child { margin-bottom: 0; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_indent_1 { text-indent: 5px; }
 #fuzngfwtrk .gt_indent_2 { text-indent: calc(5px * 2); }
 #fuzngfwtrk .gt_indent_3 { text-indent: calc(5px * 3); }
 #fuzngfwtrk .gt_indent_4 { text-indent: calc(5px * 4); }
 #fuzngfwtrk .gt_indent_5 { text-indent: calc(5px * 5); }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_row_group_first td { border-top-width: 2px; }
 #fuzngfwtrk .gt_row_group_first th { border-top-width: 2px; }
 #fuzngfwtrk .gt_striped { color: #333333; background-color: #F4F4F4; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #fuzngfwtrk .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #fuzngfwtrk .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #fuzngfwtrk .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #fuzngfwtrk .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #fuzngfwtrk .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #fuzngfwtrk .gt_left { text-align: left; }
 #fuzngfwtrk .gt_center { text-align: center; }
 #fuzngfwtrk .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #fuzngfwtrk .gt_font_normal { font-weight: normal; }
 #fuzngfwtrk .gt_font_bold { font-weight: bold; }
 #fuzngfwtrk .gt_font_italic { font-style: italic; }
 #fuzngfwtrk .gt_super { font-size: 65%; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #fuzngfwtrk .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; }
 #fuzngfwtrk .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #fuzngfwtrk .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #fuzngfwtrk .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 3.1, Ex 3.2 and P3.4: binomial and Poisson probabilities</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 3.1, 30 days, Pr{N = 0}</th>
<td class="gt_row gt_right" headers="stub-1 book">0.9138</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.9138</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 3.1, 30 days, Pr{N = 1}</th>
<td class="gt_row gt_right" headers="stub-2 book">0.0825</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.0825</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Ex 3.1, 365 days, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-3 book">0.2009</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.2009</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">Ex 3.2, 1.0 years, Pr{N = 0}</th>
<td class="gt_row gt_right" headers="stub-4 book">0.9608</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.9608</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">Ex 3.2, 1.0 years, Pr{N = 1}</th>
<td class="gt_row gt_right" headers="stub-5 book">0.0384</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.0384</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">Ex 3.2, 1.0 years, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-6 book">0.0008</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.0008</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">Ex 3.2, 1.5 years, Pr{N = 0}</th>
<td class="gt_row gt_right" headers="stub-7 book">0.9418</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.9418</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">Ex 3.2, 1.5 years, Pr{N = 1}</th>
<td class="gt_row gt_right" headers="stub-8 book">0.0565</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.0565</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">Ex 3.2, 1.5 years, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-9 book">0.0017</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">0.0017</td>
</tr>
<tr>
<th id="stub-10" class="gt_row gt_left gt_stub" scope="row">P3.4, 6 months, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-10 book">0.0012</td>
<td class="gt_row gt_right" headers="stub-10 prospicio">0.0012</td>
</tr>
<tr>
<th id="stub-11" class="gt_row gt_left gt_stub" scope="row">P3.4, 15 months, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-11 book">0.0069</td>
<td class="gt_row gt_right" headers="stub-11 prospicio">0.0069</td>
</tr>
<tr>
<th id="stub-12" class="gt_row gt_left gt_stub" scope="row">P3.4, 24 months, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-12 book">0.0164</td>
<td class="gt_row gt_right" headers="stub-12 prospicio">0.0164</td>
</tr>
</tbody>
</table>


Ex 3.3 fits a Poisson at the sample mean to 1,000 policies (868 with no claim, 118 with one, 11 with two, 2 with three, 1 with four). A chi-square test on the cells 0, 1 and 2 or more accepts it. Ex 3.8, P3.3, P3.30 and P3.31 add independent Poissons:


``` python
policies = [868, 118, 11, 2, 1]
lam = sum(k * n for k, n in enumerate(policies)) / sum(policies)
p = Poisson(lam)
rows = [("Ex 3.3, rate", 0.15, lam, 2)]
for k, book in enumerate([0.8607, 0.1291, 0.0097, 0.0005]):
    rows.append((f"Ex 3.3, Pr{{N = {k}}}", book, p.pmf(k)))
rows += [("Ex 3.3, chi-square", 2.43, chi_square([868, 118, 14], [p.pmf(0), p.pmf(1), 1 - p.cdf(1)]), 2),
         ("Ex 3.8, Pr{N >= 5}, 100 x 0.035", 0.2746, 1 - Poisson(3.5).cdf(4))]
for rate, book in [(2.5, 0.7576), (6.25, 0.1303), (2.0, 0.8571), (4.0, 0.4335)]:
    rows.append((f"P3.3, Pr{{N <= 3}}, rate {rate}", book, Poisson(rate).cdf(3)))
rows += [("P3.30, Pr{N >= 6}, 20 cars x 0.30", 0.5543, 1 - Poisson(6.0).cdf(5)),
         ("P3.31, policies with a claim, of 8,000", 624, 8000 * (1 - Poisson(650 / 8000).pmf(0)), 0)]
compare(rows, "Ex 3.3, Ex 3.8, P3.3, P3.30 and P3.31: fitting and using a Poisson")
```


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

#ofefivpked thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#ofefivpked p { margin: 0; padding: 0; }
 #ofefivpked .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; }
 #ofefivpked .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #ofefivpked .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; }
 #ofefivpked .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; }
 #ofefivpked .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; }
 #ofefivpked .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ofefivpked .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; }
 #ofefivpked .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; }
 #ofefivpked .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; }
 #ofefivpked .gt_column_spanner_outer:first-child { padding-left: 0; }
 #ofefivpked .gt_column_spanner_outer:last-child { padding-right: 0; }
 #ofefivpked .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%; }
 #ofefivpked .gt_spanner_row { border-bottom-style: hidden; }
 #ofefivpked .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; }
 #ofefivpked .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; }
 #ofefivpked .gt_from_md> :first-child { margin-top: 0; }
 #ofefivpked .gt_from_md> :last-child { margin-bottom: 0; }
 #ofefivpked .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; }
 #ofefivpked .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; }
 #ofefivpked .gt_indent_1 { text-indent: 5px; }
 #ofefivpked .gt_indent_2 { text-indent: calc(5px * 2); }
 #ofefivpked .gt_indent_3 { text-indent: calc(5px * 3); }
 #ofefivpked .gt_indent_4 { text-indent: calc(5px * 4); }
 #ofefivpked .gt_indent_5 { text-indent: calc(5px * 5); }
 #ofefivpked .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; }
 #ofefivpked .gt_row_group_first td { border-top-width: 2px; }
 #ofefivpked .gt_row_group_first th { border-top-width: 2px; }
 #ofefivpked .gt_striped { color: #333333; background-color: #F4F4F4; }
 #ofefivpked .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; }
 #ofefivpked .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #ofefivpked .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #ofefivpked .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ofefivpked .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #ofefivpked .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #ofefivpked .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #ofefivpked .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; }
 #ofefivpked .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #ofefivpked .gt_left { text-align: left; }
 #ofefivpked .gt_center { text-align: center; }
 #ofefivpked .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #ofefivpked .gt_font_normal { font-weight: normal; }
 #ofefivpked .gt_font_bold { font-weight: bold; }
 #ofefivpked .gt_font_italic { font-style: italic; }
 #ofefivpked .gt_super { font-size: 65%; }
 #ofefivpked .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; }
 #ofefivpked .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #ofefivpked .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; }
 #ofefivpked .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #ofefivpked .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #ofefivpked .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 3.3, Ex 3.8, P3.3, P3.30 and P3.31: fitting and using a Poisson</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 3.3, rate</th>
<td class="gt_row gt_right" headers="stub-1 book">0.15</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.15</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 3.3, Pr{N = 0}</th>
<td class="gt_row gt_right" headers="stub-2 book">0.8607</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.8607</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Ex 3.3, Pr{N = 1}</th>
<td class="gt_row gt_right" headers="stub-3 book">0.1291</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.1291</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">Ex 3.3, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-4 book">0.0097</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.0097</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">Ex 3.3, Pr{N = 3}</th>
<td class="gt_row gt_right" headers="stub-5 book">0.0005</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.0005</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">Ex 3.3, chi-square</th>
<td class="gt_row gt_right" headers="stub-6 book">2.43</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">2.45</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">Ex 3.8, Pr{N >= 5}, 100 x 0.035</th>
<td class="gt_row gt_right" headers="stub-7 book">0.2746</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.2746</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">P3.3, Pr{N <= 3}, rate 2.5</th>
<td class="gt_row gt_right" headers="stub-8 book">0.7576</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.7576</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">P3.3, Pr{N <= 3}, rate 6.25</th>
<td class="gt_row gt_right" headers="stub-9 book">0.1303</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">0.1303</td>
</tr>
<tr>
<th id="stub-10" class="gt_row gt_left gt_stub" scope="row">P3.3, Pr{N <= 3}, rate 2.0</th>
<td class="gt_row gt_right" headers="stub-10 book">0.8571</td>
<td class="gt_row gt_right" headers="stub-10 prospicio">0.8571</td>
</tr>
<tr>
<th id="stub-11" class="gt_row gt_left gt_stub" scope="row">P3.3, Pr{N <= 3}, rate 4.0</th>
<td class="gt_row gt_right" headers="stub-11 book">0.4335</td>
<td class="gt_row gt_right" headers="stub-11 prospicio">0.4335</td>
</tr>
<tr>
<th id="stub-12" class="gt_row gt_left gt_stub" scope="row">P3.30, Pr{N >= 6}, 20 cars x 0.30</th>
<td class="gt_row gt_right" headers="stub-12 book">0.5543</td>
<td class="gt_row gt_right" headers="stub-12 prospicio">0.5543</td>
</tr>
<tr>
<th id="stub-13" class="gt_row gt_left gt_stub" scope="row">P3.31, policies with a claim, of 8,000</th>
<td class="gt_row gt_right" headers="stub-13 book">624</td>
<td class="gt_row gt_right" headers="stub-13 prospicio">624</td>
</tr>
</tbody>
</table>


The monograph rounds the expected counts to one decimal before it sums them, which gives its chi-square of 2.43 against 2.45.


# 3. Parameter uncertainty: mixed Poissons

When each policy has its own rate, the portfolio count is a **mixed Poisson**. Its variance is the mean rate plus the variance of the rates, so it has more zeros and a heavier tail than a Poisson of the same mean. Ex 3.4 mixes four rates. Ex 3.5 draws the rate from an exponential with mean 0.25: a geometric count:


``` python
rates, weights = [0.10, 0.35, 0.70, 1.40], [0.20, 0.40, 0.30, 0.10]
mixed = [sum(w * Poisson(r).pmf(n) for r, w in zip(rates, weights)) for n in range(6)]
mean = sum(w * r for r, w in zip(rates, weights))
var = mean + sum(w * r * r for r, w in zip(rates, weights)) - mean**2
geometric = Count.mixed_poisson(0.25, 1.0, mixing="gamma")   # exponential: cv 1

pmf = pd.DataFrame({
    "n": [f"N = {n}" for n in range(6)],
    "mixed_book": [0.6365, 0.2556, 0.0788, 0.0218, 0.0056, 0.0013], "mixed": mixed,
    "poisson_book": [0.6005, 0.3063, 0.0781, 0.0133, 0.0017, 0.0002],
    "poisson": [Poisson(mean).pmf(n) for n in range(6)],
    "geo_book": [0.8, 0.16, 0.032, 0.0064, 0.0013, 0.0003],
    "geo_mixed": [geometric.pmf(n) for n in range(6)],
    "geo": [Count.geometric(0.25).pmf(n) for n in range(6)],
})
(GT(pmf, rowname_col="n")
 .tab_header("Ex 3.4 and Ex 3.5: probability of N claims")
 .tab_spanner("Ex 3.4, mixed Poisson", ["mixed_book", "mixed"])
 .tab_spanner("Ex 3.4, Poisson with mean 0.51", ["poisson_book", "poisson"])
 .tab_spanner("Ex 3.5, exponential mixing", ["geo_book", "geo_mixed", "geo"])
 .fmt_number(["mixed_book", "mixed", "poisson_book", "poisson", "geo_book", "geo_mixed", "geo"], decimals=4)
 .cols_label(mixed_book="book", mixed="prospicio", poisson_book="book", poisson="prospicio",
             geo_book="book", geo_mixed="prospicio", geo="geometric"))
```


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

#sckxpfnzji thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#sckxpfnzji p { margin: 0; padding: 0; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #sckxpfnzji .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; }
 #sckxpfnzji .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; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #sckxpfnzji .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; }
 #sckxpfnzji .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; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_column_spanner_outer:first-child { padding-left: 0; }
 #sckxpfnzji .gt_column_spanner_outer:last-child { padding-right: 0; }
 #sckxpfnzji .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%; }
 #sckxpfnzji .gt_spanner_row { border-bottom-style: hidden; }
 #sckxpfnzji .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; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_from_md> :first-child { margin-top: 0; }
 #sckxpfnzji .gt_from_md> :last-child { margin-bottom: 0; }
 #sckxpfnzji .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; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_indent_1 { text-indent: 5px; }
 #sckxpfnzji .gt_indent_2 { text-indent: calc(5px * 2); }
 #sckxpfnzji .gt_indent_3 { text-indent: calc(5px * 3); }
 #sckxpfnzji .gt_indent_4 { text-indent: calc(5px * 4); }
 #sckxpfnzji .gt_indent_5 { text-indent: calc(5px * 5); }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_row_group_first td { border-top-width: 2px; }
 #sckxpfnzji .gt_row_group_first th { border-top-width: 2px; }
 #sckxpfnzji .gt_striped { color: #333333; background-color: #F4F4F4; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #sckxpfnzji .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #sckxpfnzji .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #sckxpfnzji .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #sckxpfnzji .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #sckxpfnzji .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #sckxpfnzji .gt_left { text-align: left; }
 #sckxpfnzji .gt_center { text-align: center; }
 #sckxpfnzji .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #sckxpfnzji .gt_font_normal { font-weight: normal; }
 #sckxpfnzji .gt_font_bold { font-weight: bold; }
 #sckxpfnzji .gt_font_italic { font-style: italic; }
 #sckxpfnzji .gt_super { font-size: 65%; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #sckxpfnzji .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; }
 #sckxpfnzji .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #sckxpfnzji .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #sckxpfnzji .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="8" id="title" class="gt_heading gt_title gt_font_normal">Ex 3.4 and Ex 3.5: probability of N claims</th>
</tr>
<tr class="gt_col_headings gt_spanner_row">
<th rowspan="2" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th colspan="2" id="Ex-3.4-mixed-Poisson" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">Ex 3.4, mixed Poisson</th>
<th colspan="2" id="Ex-3.4-Poisson-with-mean-0.51" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">Ex 3.4, Poisson with mean 0.51</th>
<th colspan="3" id="Ex-3.5-exponential-mixing" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">Ex 3.5, exponential mixing</th>
</tr>
<tr class="gt_col_headings">
<th id="mixed_book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="mixed" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
<th id="poisson_book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="poisson" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
<th id="geo_book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="geo_mixed" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
<th id="geo" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">geometric</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">N = 0</th>
<td class="gt_row gt_right" headers="stub-1 Ex-3.4-mixed-Poisson mixed_book">0.6365</td>
<td class="gt_row gt_right" headers="stub-1 Ex-3.4-mixed-Poisson mixed">0.6365</td>
<td class="gt_row gt_right" headers="stub-1 Ex-3.4-Poisson-with-mean-0.51 poisson_book">0.6005</td>
<td class="gt_row gt_right" headers="stub-1 Ex-3.4-Poisson-with-mean-0.51 poisson">0.6005</td>
<td class="gt_row gt_right" headers="stub-1 Ex-3.5-exponential-mixing geo_book">0.8000</td>
<td class="gt_row gt_right" headers="stub-1 Ex-3.5-exponential-mixing geo_mixed">0.8000</td>
<td class="gt_row gt_right" headers="stub-1 Ex-3.5-exponential-mixing geo">0.8000</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">N = 1</th>
<td class="gt_row gt_right" headers="stub-2 Ex-3.4-mixed-Poisson mixed_book">0.2556</td>
<td class="gt_row gt_right" headers="stub-2 Ex-3.4-mixed-Poisson mixed">0.2556</td>
<td class="gt_row gt_right" headers="stub-2 Ex-3.4-Poisson-with-mean-0.51 poisson_book">0.3063</td>
<td class="gt_row gt_right" headers="stub-2 Ex-3.4-Poisson-with-mean-0.51 poisson">0.3063</td>
<td class="gt_row gt_right" headers="stub-2 Ex-3.5-exponential-mixing geo_book">0.1600</td>
<td class="gt_row gt_right" headers="stub-2 Ex-3.5-exponential-mixing geo_mixed">0.1600</td>
<td class="gt_row gt_right" headers="stub-2 Ex-3.5-exponential-mixing geo">0.1600</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">N = 2</th>
<td class="gt_row gt_right" headers="stub-3 Ex-3.4-mixed-Poisson mixed_book">0.0788</td>
<td class="gt_row gt_right" headers="stub-3 Ex-3.4-mixed-Poisson mixed">0.0788</td>
<td class="gt_row gt_right" headers="stub-3 Ex-3.4-Poisson-with-mean-0.51 poisson_book">0.0781</td>
<td class="gt_row gt_right" headers="stub-3 Ex-3.4-Poisson-with-mean-0.51 poisson">0.0781</td>
<td class="gt_row gt_right" headers="stub-3 Ex-3.5-exponential-mixing geo_book">0.0320</td>
<td class="gt_row gt_right" headers="stub-3 Ex-3.5-exponential-mixing geo_mixed">0.0320</td>
<td class="gt_row gt_right" headers="stub-3 Ex-3.5-exponential-mixing geo">0.0320</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">N = 3</th>
<td class="gt_row gt_right" headers="stub-4 Ex-3.4-mixed-Poisson mixed_book">0.0218</td>
<td class="gt_row gt_right" headers="stub-4 Ex-3.4-mixed-Poisson mixed">0.0218</td>
<td class="gt_row gt_right" headers="stub-4 Ex-3.4-Poisson-with-mean-0.51 poisson_book">0.0133</td>
<td class="gt_row gt_right" headers="stub-4 Ex-3.4-Poisson-with-mean-0.51 poisson">0.0133</td>
<td class="gt_row gt_right" headers="stub-4 Ex-3.5-exponential-mixing geo_book">0.0064</td>
<td class="gt_row gt_right" headers="stub-4 Ex-3.5-exponential-mixing geo_mixed">0.0064</td>
<td class="gt_row gt_right" headers="stub-4 Ex-3.5-exponential-mixing geo">0.0064</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">N = 4</th>
<td class="gt_row gt_right" headers="stub-5 Ex-3.4-mixed-Poisson mixed_book">0.0056</td>
<td class="gt_row gt_right" headers="stub-5 Ex-3.4-mixed-Poisson mixed">0.0056</td>
<td class="gt_row gt_right" headers="stub-5 Ex-3.4-Poisson-with-mean-0.51 poisson_book">0.0017</td>
<td class="gt_row gt_right" headers="stub-5 Ex-3.4-Poisson-with-mean-0.51 poisson">0.0017</td>
<td class="gt_row gt_right" headers="stub-5 Ex-3.5-exponential-mixing geo_book">0.0013</td>
<td class="gt_row gt_right" headers="stub-5 Ex-3.5-exponential-mixing geo_mixed">0.0013</td>
<td class="gt_row gt_right" headers="stub-5 Ex-3.5-exponential-mixing geo">0.0013</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">N = 5</th>
<td class="gt_row gt_right" headers="stub-6 Ex-3.4-mixed-Poisson mixed_book">0.0013</td>
<td class="gt_row gt_right" headers="stub-6 Ex-3.4-mixed-Poisson mixed">0.0013</td>
<td class="gt_row gt_right" headers="stub-6 Ex-3.4-Poisson-with-mean-0.51 poisson_book">0.0002</td>
<td class="gt_row gt_right" headers="stub-6 Ex-3.4-Poisson-with-mean-0.51 poisson">0.0002</td>
<td class="gt_row gt_right" headers="stub-6 Ex-3.5-exponential-mixing geo_book">0.0003</td>
<td class="gt_row gt_right" headers="stub-6 Ex-3.5-exponential-mixing geo_mixed">0.0003</td>
<td class="gt_row gt_right" headers="stub-6 Ex-3.5-exponential-mixing geo">0.0003</td>
</tr>
</tbody>
</table>


Ex 3.4 against the Poisson with the same mean:


``` python
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.bar(range(6), [Poisson(mean).pmf(n) for n in range(6)], color="0.75",
       label="Poisson, mean 0.51")
ax.plot(range(6), mixed, marker="o", label="mixed Poisson, Ex 3.4")
ax.set_xlabel("number of claims N")
ax.set_ylabel("probability")
ax.set_title("Ex 3.4: the mixture against the Poisson with the same mean")
ax.legend()
```


<figure class="p-figure figure">
PSIzOTUuMDUwNzIzIiB5PSIyMjEuNTA2MDU4IiBzdHlsZT0iZmlsbDogdmFyKC0tcC1zZXJpZXMtMSk7IHN0cm9rZTogdmFyKC0tcC1zZXJpZXMtMSkiIC8+CiAgICA8L2c+CiAgIDwvZz4KICAgPGcgaWQ9InBhdGNoXzkiPgogICAgPHBhdGggZD0iTSA0Ni42OTQyOTcgMjIxLjkwMjEyNSAKTCA0Ni42OTQyOTcgMjIuMzE4MTI1IAoiIHN0eWxlPSJmaWxsOiBub25lOyBzdHJva2U6IHZhcigtLXAtcnVsZSk7IHN0cm9rZS13aWR0aDogMC44OyBzdHJva2UtbGluZWpvaW46IG1pdGVyOyBzdHJva2UtbGluZWNhcDogc3F1YXJlIiAvPgogICA8L2c+CiAgIDxnIGlkPSJwYXRjaF8xMC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IiB3aWR0aD0iMzkwLjYiIGhlaWdodD0iMTk5LjU4NCIgLz4KICA8L2NsaXBwYXRoPgogPC9kZWZzPgo8L3N2Zz4=" />
</figure>


Gamma rates give a negative binomial, the standard overdispersed count. P3.11 uses a gamma with shape 2 and scale 1, P3.12 one with mean 0.100 and variance 0.005. P3.13 compares a Poisson, a two-point mixture and an exponential mixture of one mean:


``` python
nb = NegativeBinomial(2.0, 1.0)
rows = [("Ex 3.4, Var[N]", 0.6439, var),
        ("Ex 3.5, Var[N]", 0.3125, geometric.variance()),
        ("P3.11, mean", 2, nb.mean(), 0),
        ("P3.11, variance", 4, nb.variance(), 0),
        ("P3.11, Pr{N <= 3}", 0.8125, nb.cdf(3))]
nb = NegativeBinomial.from_mean_variance(0.100, 0.100 + 0.005)  # Var[N] = E + Var[rate]
for n, book in enumerate([0.9070, 0.0864, 0.0062, 0.0004]):
    rows.append((f"P3.12, Pr{{N = {n}}}", book, nb.pmf(n)))
two_point_var = 0.75 + (0.75 * 0.6**2 + 0.25 * 1.2**2 - 0.75**2)
rows += [("P3.13, Var, Poisson 0.75", 0.7500, Poisson(0.75).variance()),
         ("P3.13, Var, two-point mixture", 0.8175, two_point_var),
         ("P3.13, Var, exponential mixture", 1.3125, Count.mixed_poisson(0.75, 1.0).variance())]
compare(rows, "Ex 3.4, Ex 3.5 and P3.11 to P3.13: variances and gamma mixtures")
```


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

#ecgtjwwzts thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#ecgtjwwzts p { margin: 0; padding: 0; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_column_spanner_outer:first-child { padding-left: 0; }
 #ecgtjwwzts .gt_column_spanner_outer:last-child { padding-right: 0; }
 #ecgtjwwzts .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%; }
 #ecgtjwwzts .gt_spanner_row { border-bottom-style: hidden; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_from_md> :first-child { margin-top: 0; }
 #ecgtjwwzts .gt_from_md> :last-child { margin-bottom: 0; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_indent_1 { text-indent: 5px; }
 #ecgtjwwzts .gt_indent_2 { text-indent: calc(5px * 2); }
 #ecgtjwwzts .gt_indent_3 { text-indent: calc(5px * 3); }
 #ecgtjwwzts .gt_indent_4 { text-indent: calc(5px * 4); }
 #ecgtjwwzts .gt_indent_5 { text-indent: calc(5px * 5); }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_row_group_first td { border-top-width: 2px; }
 #ecgtjwwzts .gt_row_group_first th { border-top-width: 2px; }
 #ecgtjwwzts .gt_striped { color: #333333; background-color: #F4F4F4; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #ecgtjwwzts .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #ecgtjwwzts .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ecgtjwwzts .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #ecgtjwwzts .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #ecgtjwwzts .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #ecgtjwwzts .gt_left { text-align: left; }
 #ecgtjwwzts .gt_center { text-align: center; }
 #ecgtjwwzts .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #ecgtjwwzts .gt_font_normal { font-weight: normal; }
 #ecgtjwwzts .gt_font_bold { font-weight: bold; }
 #ecgtjwwzts .gt_font_italic { font-style: italic; }
 #ecgtjwwzts .gt_super { font-size: 65%; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #ecgtjwwzts .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; }
 #ecgtjwwzts .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #ecgtjwwzts .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #ecgtjwwzts .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 3.4, Ex 3.5 and P3.11 to P3.13: variances and gamma mixtures</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 3.4, Var[N]</th>
<td class="gt_row gt_right" headers="stub-1 book">0.6439</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.6439</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 3.5, Var[N]</th>
<td class="gt_row gt_right" headers="stub-2 book">0.3125</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.3125</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">P3.11, mean</th>
<td class="gt_row gt_right" headers="stub-3 book">2</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">2</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">P3.11, variance</th>
<td class="gt_row gt_right" headers="stub-4 book">4</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">4</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">P3.11, Pr{N <= 3}</th>
<td class="gt_row gt_right" headers="stub-5 book">0.8125</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.8125</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">P3.12, Pr{N = 0}</th>
<td class="gt_row gt_right" headers="stub-6 book">0.9070</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.9070</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">P3.12, Pr{N = 1}</th>
<td class="gt_row gt_right" headers="stub-7 book">0.0864</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.0864</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">P3.12, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-8 book">0.0062</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.0062</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">P3.12, Pr{N = 3}</th>
<td class="gt_row gt_right" headers="stub-9 book">0.0004</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">0.0004</td>
</tr>
<tr>
<th id="stub-10" class="gt_row gt_left gt_stub" scope="row">P3.13, Var, Poisson 0.75</th>
<td class="gt_row gt_right" headers="stub-10 book">0.7500</td>
<td class="gt_row gt_right" headers="stub-10 prospicio">0.7500</td>
</tr>
<tr>
<th id="stub-11" class="gt_row gt_left gt_stub" scope="row">P3.13, Var, two-point mixture</th>
<td class="gt_row gt_right" headers="stub-11 book">0.8175</td>
<td class="gt_row gt_right" headers="stub-11 prospicio">0.8175</td>
</tr>
<tr>
<th id="stub-12" class="gt_row gt_left gt_stub" scope="row">P3.13, Var, exponential mixture</th>
<td class="gt_row gt_right" headers="stub-12 book">1.3125</td>
<td class="gt_row gt_right" headers="stub-12 prospicio">1.3125</td>
</tr>
</tbody>
</table>


# 4. The negative binomial and contagion

Ex 3.6 and P3.15 fit a negative binomial by moments to 5,000 auto liability and 10,000 policies. The sample variance exceeds the mean, so a Poisson is too thin. A chi-square test on the cells 0, 1, 2 and 3 or more tests each fit:


``` python
def nb_moments(counts):
    n = sum(counts)
    m1 = sum(k * c for k, c in enumerate(counts)) / n
    m2 = sum(k * k * c for k, c in enumerate(counts)) / n
    return m1, m2 - m1**2


rows = []
for name, counts, book in [
    ("Ex 3.6", [4429, 528, 39, 3, 1], (0.1238, 2.44285, 0.7753)),
    ("P3.15", [8956, 907, 120, 15, 2], (0.1200, 0.685714, 0.3288)),
]:
    mean, var = nb_moments(counts)
    nb = NegativeBinomial.from_mean_variance(mean, var)
    probs = [nb.pmf(0), nb.pmf(1), nb.pmf(2), 1 - nb.cdf(2)]
    observed = counts[:3] + [sum(counts[3:])]
    rows += [(f"{name}, mean", book[0], mean),
             (f"{name}, alpha = r", book[1], nb.r, 5),
             (f"{name}, chi-square", book[2], chi_square(observed, probs))]
    if name == "Ex 3.6":
        for k, book_pmf in enumerate([0.8862, 0.1044, 0.0087, 0.0006]):
            rows.append((f"Ex 3.6, Pr{{N = {k}}}", book_pmf, nb.pmf(k)))
compare(rows, "Ex 3.6 and P3.15: negative binomials fitted by moments")
```


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

#ntbthfcykl thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#ntbthfcykl p { margin: 0; padding: 0; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #ntbthfcykl .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; }
 #ntbthfcykl .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; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ntbthfcykl .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; }
 #ntbthfcykl .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; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_column_spanner_outer:first-child { padding-left: 0; }
 #ntbthfcykl .gt_column_spanner_outer:last-child { padding-right: 0; }
 #ntbthfcykl .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%; }
 #ntbthfcykl .gt_spanner_row { border-bottom-style: hidden; }
 #ntbthfcykl .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; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_from_md> :first-child { margin-top: 0; }
 #ntbthfcykl .gt_from_md> :last-child { margin-bottom: 0; }
 #ntbthfcykl .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; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_indent_1 { text-indent: 5px; }
 #ntbthfcykl .gt_indent_2 { text-indent: calc(5px * 2); }
 #ntbthfcykl .gt_indent_3 { text-indent: calc(5px * 3); }
 #ntbthfcykl .gt_indent_4 { text-indent: calc(5px * 4); }
 #ntbthfcykl .gt_indent_5 { text-indent: calc(5px * 5); }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_row_group_first td { border-top-width: 2px; }
 #ntbthfcykl .gt_row_group_first th { border-top-width: 2px; }
 #ntbthfcykl .gt_striped { color: #333333; background-color: #F4F4F4; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #ntbthfcykl .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #ntbthfcykl .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #ntbthfcykl .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #ntbthfcykl .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #ntbthfcykl .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #ntbthfcykl .gt_left { text-align: left; }
 #ntbthfcykl .gt_center { text-align: center; }
 #ntbthfcykl .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #ntbthfcykl .gt_font_normal { font-weight: normal; }
 #ntbthfcykl .gt_font_bold { font-weight: bold; }
 #ntbthfcykl .gt_font_italic { font-style: italic; }
 #ntbthfcykl .gt_super { font-size: 65%; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #ntbthfcykl .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; }
 #ntbthfcykl .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #ntbthfcykl .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #ntbthfcykl .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 3.6 and P3.15: negative binomials fitted by moments</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 3.6, mean</th>
<td class="gt_row gt_right" headers="stub-1 book">0.1238</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.1238</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 3.6, alpha = r</th>
<td class="gt_row gt_right" headers="stub-2 book">2.44285</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">2.44302</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Ex 3.6, chi-square</th>
<td class="gt_row gt_right" headers="stub-3 book">0.7753</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.6464</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">Ex 3.6, Pr{N = 0}</th>
<td class="gt_row gt_right" headers="stub-4 book">0.8862</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.8862</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">Ex 3.6, Pr{N = 1}</th>
<td class="gt_row gt_right" headers="stub-5 book">0.1044</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.1044</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">Ex 3.6, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-6 book">0.0087</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.0087</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">Ex 3.6, Pr{N = 3}</th>
<td class="gt_row gt_right" headers="stub-7 book">0.0006</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.0006</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">P3.15, mean</th>
<td class="gt_row gt_right" headers="stub-8 book">0.1200</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.1200</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">P3.15, alpha = r</th>
<td class="gt_row gt_right" headers="stub-9 book">0.68571</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">0.68571</td>
</tr>
<tr>
<th id="stub-10" class="gt_row gt_left gt_stub" scope="row">P3.15, chi-square</th>
<td class="gt_row gt_right" headers="stub-10 book">0.3288</td>
<td class="gt_row gt_right" headers="stub-10 prospicio">0.3288</td>
</tr>
</tbody>
</table>


In Ex 3.6, α differs in the fourth decimal because the monograph rounds the sample variance to 0.130074 (it is 0.13007356) before it divides by the small excess over the mean. The fitted probabilities agree. Its chi-square of 0.7753 does not reproduce: with the printed probabilities, or with α = 2.44285, the statistic is near 0.6 to 0.65, so the printed value probably comes from other cells or expected counts.

**Contagion** is the monograph's other route to the negative binomial. If each claim makes the next more likely, Var\[N\] = ν + γν², and a Pólya urn gives r = 1/γ. For any count, γ = (Var\[N\] − E\[N\])/E\[N\]²: 0 for a Poisson, negative for a binomial. P3.28 asks for mean 1 and γ = 0.2. Ex 3.9 and P3.29 add independent policies. Means and variances add, so the contagion shrinks as the portfolio grows:


``` python
nb = claim_count(1.0, 1 + 0.2 * 1.0)       # dispersion Var/E = 1 + gamma * mean


def contagion(counts):
    mean = sum(c.mean() for c in counts)
    var = sum(c.variance() for c in counts)
    return (var - mean) / mean**2


rows = [(f"P3.28, Pr{{N = {n}}}", book, nb.pmf(n))
        for n, book in enumerate([0.4019, 0.3349, 0.1674, 0.0651, 0.0217, 0.0065])]
rows += [("Ex 3.9, contagion, 20 policies, nu 0.15, gamma 0.4", 0.020,
          contagion([claim_count(0.15, 1 + 0.4 * 0.15)] * 20), 3),
         ("P3.29, contagion, three lines", 0.1000,
          contagion([claim_count(10, 1 + 0.35 * 10), claim_count(25, 1 + 0.20 * 25), Poisson(5.0)]))]
compare(rows, "P3.28, Ex 3.9 and P3.29: contagion")
```


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

#irkyxpbieq thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#irkyxpbieq p { margin: 0; padding: 0; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #irkyxpbieq .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; }
 #irkyxpbieq .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; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #irkyxpbieq .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; }
 #irkyxpbieq .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; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_column_spanner_outer:first-child { padding-left: 0; }
 #irkyxpbieq .gt_column_spanner_outer:last-child { padding-right: 0; }
 #irkyxpbieq .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%; }
 #irkyxpbieq .gt_spanner_row { border-bottom-style: hidden; }
 #irkyxpbieq .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; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_from_md> :first-child { margin-top: 0; }
 #irkyxpbieq .gt_from_md> :last-child { margin-bottom: 0; }
 #irkyxpbieq .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; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_indent_1 { text-indent: 5px; }
 #irkyxpbieq .gt_indent_2 { text-indent: calc(5px * 2); }
 #irkyxpbieq .gt_indent_3 { text-indent: calc(5px * 3); }
 #irkyxpbieq .gt_indent_4 { text-indent: calc(5px * 4); }
 #irkyxpbieq .gt_indent_5 { text-indent: calc(5px * 5); }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_row_group_first td { border-top-width: 2px; }
 #irkyxpbieq .gt_row_group_first th { border-top-width: 2px; }
 #irkyxpbieq .gt_striped { color: #333333; background-color: #F4F4F4; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #irkyxpbieq .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #irkyxpbieq .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #irkyxpbieq .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #irkyxpbieq .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #irkyxpbieq .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #irkyxpbieq .gt_left { text-align: left; }
 #irkyxpbieq .gt_center { text-align: center; }
 #irkyxpbieq .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #irkyxpbieq .gt_font_normal { font-weight: normal; }
 #irkyxpbieq .gt_font_bold { font-weight: bold; }
 #irkyxpbieq .gt_font_italic { font-style: italic; }
 #irkyxpbieq .gt_super { font-size: 65%; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #irkyxpbieq .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; }
 #irkyxpbieq .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #irkyxpbieq .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #irkyxpbieq .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">P3.28, Ex 3.9 and P3.29: contagion</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">P3.28, Pr{N = 0}</th>
<td class="gt_row gt_right" headers="stub-1 book">0.4019</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.4019</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">P3.28, Pr{N = 1}</th>
<td class="gt_row gt_right" headers="stub-2 book">0.3349</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.3349</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">P3.28, Pr{N = 2}</th>
<td class="gt_row gt_right" headers="stub-3 book">0.1674</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.1674</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">P3.28, Pr{N = 3}</th>
<td class="gt_row gt_right" headers="stub-4 book">0.0651</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.0651</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">P3.28, Pr{N = 4}</th>
<td class="gt_row gt_right" headers="stub-5 book">0.0217</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.0217</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">P3.28, Pr{N = 5}</th>
<td class="gt_row gt_right" headers="stub-6 book">0.0065</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.0065</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">Ex 3.9, contagion, 20 policies, nu 0.15, gamma 0.4</th>
<td class="gt_row gt_right" headers="stub-7 book">0.020</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.020</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">P3.29, contagion, three lines</th>
<td class="gt_row gt_right" headers="stub-8 book">0.1000</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.1000</td>
</tr>
</tbody>
</table>


For claims above an attachment, each claim stays with probability p. A Poisson λ becomes Poisson pλ. A negative binomial keeps its γ and its mean becomes pν: build the thinned count from them (section 7 of the first guide, Ex 5.9 and 5.11).


# 5. Aggregate claims and their moments

The year's total S sums N claims: E\[S\] = E\[N\]E\[X\] and Var\[S\] = E\[N\]Var\[X\] + Var\[N\]E\[X\]². [compound_moments](../reference/aggregate.compound_moments.md#prospicio.aggregate.compound_moments) returns the first three moments, [fft](../reference/aggregate.fft.md#prospicio.aggregate.fft) the whole distribution. Ex 4.1 and P4.1 are small discrete examples:


``` python
count = Count.empirical([0.6, 0.3, 0.1])
size = Grid(100.0, [0.0, 0.4, 0.5, 0.1])             # 100, 200, 300
agg, _ = fft(count, size, 16)
rows = [(f"Ex 4.1, F_S({100 * k})", book, agg.cdf(100.0 * k))
        for k, book in enumerate([0.6, 0.72, 0.886, 0.956, 0.989, 0.999, 1.0])]
rows += [("Ex 4.1, E[S]", 85, agg.mean(), 0), ("Ex 4.1, Var[S]", 15_055, agg.variance(), 0)]
compare(rows, "Ex 4.1: a small discrete aggregate")
```


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

#rimkrieyrj thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#rimkrieyrj p { margin: 0; padding: 0; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #rimkrieyrj .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; }
 #rimkrieyrj .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; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #rimkrieyrj .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; }
 #rimkrieyrj .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; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_column_spanner_outer:first-child { padding-left: 0; }
 #rimkrieyrj .gt_column_spanner_outer:last-child { padding-right: 0; }
 #rimkrieyrj .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%; }
 #rimkrieyrj .gt_spanner_row { border-bottom-style: hidden; }
 #rimkrieyrj .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; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_from_md> :first-child { margin-top: 0; }
 #rimkrieyrj .gt_from_md> :last-child { margin-bottom: 0; }
 #rimkrieyrj .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; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_indent_1 { text-indent: 5px; }
 #rimkrieyrj .gt_indent_2 { text-indent: calc(5px * 2); }
 #rimkrieyrj .gt_indent_3 { text-indent: calc(5px * 3); }
 #rimkrieyrj .gt_indent_4 { text-indent: calc(5px * 4); }
 #rimkrieyrj .gt_indent_5 { text-indent: calc(5px * 5); }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_row_group_first td { border-top-width: 2px; }
 #rimkrieyrj .gt_row_group_first th { border-top-width: 2px; }
 #rimkrieyrj .gt_striped { color: #333333; background-color: #F4F4F4; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #rimkrieyrj .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #rimkrieyrj .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #rimkrieyrj .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #rimkrieyrj .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #rimkrieyrj .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #rimkrieyrj .gt_left { text-align: left; }
 #rimkrieyrj .gt_center { text-align: center; }
 #rimkrieyrj .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #rimkrieyrj .gt_font_normal { font-weight: normal; }
 #rimkrieyrj .gt_font_bold { font-weight: bold; }
 #rimkrieyrj .gt_font_italic { font-style: italic; }
 #rimkrieyrj .gt_super { font-size: 65%; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #rimkrieyrj .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; }
 #rimkrieyrj .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #rimkrieyrj .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #rimkrieyrj .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 4.1: a small discrete aggregate</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, F_S(0)</th>
<td class="gt_row gt_right" headers="stub-1 book">0.6000</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.6000</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, F_S(100)</th>
<td class="gt_row gt_right" headers="stub-2 book">0.7200</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.7200</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, F_S(200)</th>
<td class="gt_row gt_right" headers="stub-3 book">0.8860</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.8860</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, F_S(300)</th>
<td class="gt_row gt_right" headers="stub-4 book">0.9560</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.9560</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, F_S(400)</th>
<td class="gt_row gt_right" headers="stub-5 book">0.9890</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.9890</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, F_S(500)</th>
<td class="gt_row gt_right" headers="stub-6 book">0.9990</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.9990</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, F_S(600)</th>
<td class="gt_row gt_right" headers="stub-7 book">1.0000</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">1.0000</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, E[S]</th>
<td class="gt_row gt_right" headers="stub-8 book">85</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">85</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">Ex 4.1, Var[S]</th>
<td class="gt_row gt_right" headers="stub-9 book">15,055</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">15,055</td>
</tr>
</tbody>
</table>


``` python
count = Count.empirical([0.20, 0.40, 0.25, 0.15])
size = Grid(500.0, [0.0, 0.1, 0.4, 0.3, 0.2])        # 500 to 2,000
agg, _ = fft(count, size, 16)
book = [0.2, 0.24, 0.4025, 0.5427, 0.6795, 0.758, 0.8418, 0.9047, 0.9507]
compare([(f"P4.1, F_S({500 * k:,})", b, agg.cdf(500.0 * k)) for k, b in enumerate(book)],
        "P4.1: the aggregate distribution")
```


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

#yoeubietzb thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#yoeubietzb p { margin: 0; padding: 0; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #yoeubietzb .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; }
 #yoeubietzb .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; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #yoeubietzb .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; }
 #yoeubietzb .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; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_column_spanner_outer:first-child { padding-left: 0; }
 #yoeubietzb .gt_column_spanner_outer:last-child { padding-right: 0; }
 #yoeubietzb .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%; }
 #yoeubietzb .gt_spanner_row { border-bottom-style: hidden; }
 #yoeubietzb .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; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_from_md> :first-child { margin-top: 0; }
 #yoeubietzb .gt_from_md> :last-child { margin-bottom: 0; }
 #yoeubietzb .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; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_indent_1 { text-indent: 5px; }
 #yoeubietzb .gt_indent_2 { text-indent: calc(5px * 2); }
 #yoeubietzb .gt_indent_3 { text-indent: calc(5px * 3); }
 #yoeubietzb .gt_indent_4 { text-indent: calc(5px * 4); }
 #yoeubietzb .gt_indent_5 { text-indent: calc(5px * 5); }
 #yoeubietzb .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; }
 #yoeubietzb .gt_row_group_first td { border-top-width: 2px; }
 #yoeubietzb .gt_row_group_first th { border-top-width: 2px; }
 #yoeubietzb .gt_striped { color: #333333; background-color: #F4F4F4; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #yoeubietzb .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #yoeubietzb .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #yoeubietzb .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #yoeubietzb .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #yoeubietzb .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #yoeubietzb .gt_left { text-align: left; }
 #yoeubietzb .gt_center { text-align: center; }
 #yoeubietzb .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #yoeubietzb .gt_font_normal { font-weight: normal; }
 #yoeubietzb .gt_font_bold { font-weight: bold; }
 #yoeubietzb .gt_font_italic { font-style: italic; }
 #yoeubietzb .gt_super { font-size: 65%; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #yoeubietzb .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; }
 #yoeubietzb .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #yoeubietzb .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #yoeubietzb .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">P4.1: the aggregate distribution</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(0)</th>
<td class="gt_row gt_right" headers="stub-1 book">0.2000</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.2000</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(500)</th>
<td class="gt_row gt_right" headers="stub-2 book">0.2400</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.2400</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(1,000)</th>
<td class="gt_row gt_right" headers="stub-3 book">0.4025</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.4025</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(1,500)</th>
<td class="gt_row gt_right" headers="stub-4 book">0.5427</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.5427</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(2,000)</th>
<td class="gt_row gt_right" headers="stub-5 book">0.6795</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.6795</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(2,500)</th>
<td class="gt_row gt_right" headers="stub-6 book">0.7580</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.7580</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(3,000)</th>
<td class="gt_row gt_right" headers="stub-7 book">0.8418</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.8418</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(3,500)</th>
<td class="gt_row gt_right" headers="stub-8 book">0.9047</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.9047</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">P4.1, F_S(4,000)</th>
<td class="gt_row gt_right" headers="stub-9 book">0.9507</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">0.9507</td>
</tr>
</tbody>
</table>


Ex 4.2 has a Poisson 2.5 count and gamma claims (shape 3, scale 400). A sum of n claims is a gamma with shape 3n, so the distribution is an exact series over n. Table 4.1 is that series:


``` python
lam, size = 2.5, Gamma(3.0, 400.0)
moments = compound_moments(Poisson(lam), size)


def poisson_gamma_cdf(s, lam, shape, scale, terms=400):
    n = Poisson(lam)
    if s <= 0:
        return n.pmf(0)
    return n.pmf(0) + sum(n.pmf(k) * Gamma(shape * k, scale).cdf(s) for k in range(1, terms))


S = [0, 500, 1000, 2000, 3000, 4000, 6000, 8000, 10000]
book = [0.0821, 0.1096, 0.1867, 0.3755, 0.5613, 0.7152, 0.9013, 0.9723, 0.9934]
rows = [("Ex 4.2, E[S]", 3_000, moments.mean, 0),
        ("Ex 4.2, Var[S]", 4_800_000, moments.variance, 0),
        ("Ex 4.2, skewness", 0.9129, moments.skew)]
rows += [(f"Ex 4.2, F({s:,})", b, poisson_gamma_cdf(s, lam, 3.0, 400.0)) for s, b in zip(S, book)]
compare(rows, "Ex 4.2 and Table 4.1: Poisson 2.5 with gamma (3; 400) claims")
```


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

#kxztdirvme thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#kxztdirvme p { margin: 0; padding: 0; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #kxztdirvme .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; }
 #kxztdirvme .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; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #kxztdirvme .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; }
 #kxztdirvme .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; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_column_spanner_outer:first-child { padding-left: 0; }
 #kxztdirvme .gt_column_spanner_outer:last-child { padding-right: 0; }
 #kxztdirvme .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%; }
 #kxztdirvme .gt_spanner_row { border-bottom-style: hidden; }
 #kxztdirvme .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; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_from_md> :first-child { margin-top: 0; }
 #kxztdirvme .gt_from_md> :last-child { margin-bottom: 0; }
 #kxztdirvme .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; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_indent_1 { text-indent: 5px; }
 #kxztdirvme .gt_indent_2 { text-indent: calc(5px * 2); }
 #kxztdirvme .gt_indent_3 { text-indent: calc(5px * 3); }
 #kxztdirvme .gt_indent_4 { text-indent: calc(5px * 4); }
 #kxztdirvme .gt_indent_5 { text-indent: calc(5px * 5); }
 #kxztdirvme .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; }
 #kxztdirvme .gt_row_group_first td { border-top-width: 2px; }
 #kxztdirvme .gt_row_group_first th { border-top-width: 2px; }
 #kxztdirvme .gt_striped { color: #333333; background-color: #F4F4F4; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #kxztdirvme .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #kxztdirvme .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #kxztdirvme .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #kxztdirvme .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #kxztdirvme .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #kxztdirvme .gt_left { text-align: left; }
 #kxztdirvme .gt_center { text-align: center; }
 #kxztdirvme .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #kxztdirvme .gt_font_normal { font-weight: normal; }
 #kxztdirvme .gt_font_bold { font-weight: bold; }
 #kxztdirvme .gt_font_italic { font-style: italic; }
 #kxztdirvme .gt_super { font-size: 65%; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #kxztdirvme .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; }
 #kxztdirvme .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #kxztdirvme .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #kxztdirvme .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 4.2 and Table 4.1: Poisson 2.5 with gamma (3; 400) claims</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, E[S]</th>
<td class="gt_row gt_right" headers="stub-1 book">3,000</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">3,000</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, Var[S]</th>
<td class="gt_row gt_right" headers="stub-2 book">4,800,000</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">4,800,000</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, skewness</th>
<td class="gt_row gt_right" headers="stub-3 book">0.9129</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.9129</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(0)</th>
<td class="gt_row gt_right" headers="stub-4 book">0.0821</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.0821</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(500)</th>
<td class="gt_row gt_right" headers="stub-5 book">0.1096</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.1096</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(1,000)</th>
<td class="gt_row gt_right" headers="stub-6 book">0.1867</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.1867</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(2,000)</th>
<td class="gt_row gt_right" headers="stub-7 book">0.3755</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.3755</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(3,000)</th>
<td class="gt_row gt_right" headers="stub-8 book">0.5613</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.5613</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(4,000)</th>
<td class="gt_row gt_right" headers="stub-9 book">0.7152</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">0.7152</td>
</tr>
<tr>
<th id="stub-10" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(6,000)</th>
<td class="gt_row gt_right" headers="stub-10 book">0.9013</td>
<td class="gt_row gt_right" headers="stub-10 prospicio">0.9013</td>
</tr>
<tr>
<th id="stub-11" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(8,000)</th>
<td class="gt_row gt_right" headers="stub-11 book">0.9723</td>
<td class="gt_row gt_right" headers="stub-11 prospicio">0.9723</td>
</tr>
<tr>
<th id="stub-12" class="gt_row gt_left gt_stub" scope="row">Ex 4.2, F(10,000)</th>
<td class="gt_row gt_right" headers="stub-12 book">0.9934</td>
<td class="gt_row gt_right" headers="stub-12 prospicio">0.9934</td>
</tr>
</tbody>
</table>


# 6. Approximations by matching moments

Actuaries once matched a distribution to the aggregate's mean, variance and, where the family allows, skewness. The normal ignores skewness. The shifted gamma matches three moments. [CompoundMoments.approximate](../reference/aggregate.CompoundMoments.md#prospicio.aggregate.CompoundMoments.approximate) offers these and the gamma, lognormal, shifted lognormal, normal power and Wilson-Hilferty. Table 4.3 is Ex 4.2. Table 4.4 is far more skewed (Poisson 10, gamma with shape 0.05 and scale 6,000). P4.13 has a Poisson 8 with gamma shape 0.2 and scale 3,750:


``` python
cases = [
    ("Table 4.3", 4, 2.5, 3.0, 400.0, [0, 2000, 4000, 6000, 8000],
     [0.0821, 0.3755, 0.7152, 0.9013, 0.9723], [0.0855, 0.3240, 0.6760, 0.9145, 0.9888],
     [0.0459, 0.3680, 0.7185, 0.9038, 0.9724]),
    ("Table 4.4", 5, 10.0, 0.05, 6000.0, [0, 2000, 6000, 10000, 18000],
     [0.00005, 0.5922, 0.8401, 0.9294, 0.9846], [0.2451, 0.4090, 0.7549, 0.9463, 0.9997],
     [0.1228, 0.5886, 0.8402, 0.9298, 0.9847]),
    ("P4.13", 4, 8.0, 0.2, 3750.0, [0, 3000, 9000, 15000, 27000],
     [0.0003, 0.3420, 0.7774, 0.9349, 0.9954], [0.1241, 0.2819, 0.7181, 0.9584, 1.0000],
     [0.0263, 0.3362, 0.7782, 0.9356, 0.9953]),
]
moment_rows = []
for name, _, lam, shape, scale, *_rest in cases:
    m = compound_moments(Poisson(lam), Gamma(shape, scale))
    moment_rows.append((name, m.mean, m.variance ** 0.5, m.skew))
(GT(pd.DataFrame(moment_rows, columns=["case", "mean", "sd", "skewness"]), rowname_col="case")
 .tab_header("Tables 4.3, 4.4 and P4.13: the aggregate's moments")
 .fmt_number(["mean", "sd"], decimals=0)
 .fmt_number("skewness", decimals=4))
```


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

#zyyxbetaof thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#zyyxbetaof p { margin: 0; padding: 0; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #zyyxbetaof .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; }
 #zyyxbetaof .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; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #zyyxbetaof .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; }
 #zyyxbetaof .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; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_column_spanner_outer:first-child { padding-left: 0; }
 #zyyxbetaof .gt_column_spanner_outer:last-child { padding-right: 0; }
 #zyyxbetaof .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%; }
 #zyyxbetaof .gt_spanner_row { border-bottom-style: hidden; }
 #zyyxbetaof .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; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_from_md> :first-child { margin-top: 0; }
 #zyyxbetaof .gt_from_md> :last-child { margin-bottom: 0; }
 #zyyxbetaof .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; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_indent_1 { text-indent: 5px; }
 #zyyxbetaof .gt_indent_2 { text-indent: calc(5px * 2); }
 #zyyxbetaof .gt_indent_3 { text-indent: calc(5px * 3); }
 #zyyxbetaof .gt_indent_4 { text-indent: calc(5px * 4); }
 #zyyxbetaof .gt_indent_5 { text-indent: calc(5px * 5); }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_row_group_first td { border-top-width: 2px; }
 #zyyxbetaof .gt_row_group_first th { border-top-width: 2px; }
 #zyyxbetaof .gt_striped { color: #333333; background-color: #F4F4F4; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #zyyxbetaof .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #zyyxbetaof .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #zyyxbetaof .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #zyyxbetaof .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #zyyxbetaof .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #zyyxbetaof .gt_left { text-align: left; }
 #zyyxbetaof .gt_center { text-align: center; }
 #zyyxbetaof .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #zyyxbetaof .gt_font_normal { font-weight: normal; }
 #zyyxbetaof .gt_font_bold { font-weight: bold; }
 #zyyxbetaof .gt_font_italic { font-style: italic; }
 #zyyxbetaof .gt_super { font-size: 65%; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #zyyxbetaof .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; }
 #zyyxbetaof .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #zyyxbetaof .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #zyyxbetaof .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Tables 4.3, 4.4 and P4.13: the aggregate's moments</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="sd" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">sd</th>
<th id="skewness" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">skewness</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Table 4.3</th>
<td class="gt_row gt_right" headers="stub-1 mean">3,000</td>
<td class="gt_row gt_right" headers="stub-1 sd">2,191</td>
<td class="gt_row gt_right" headers="stub-1 skewness">0.9129</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Table 4.4</th>
<td class="gt_row gt_right" headers="stub-2 mean">3,000</td>
<td class="gt_row gt_right" headers="stub-2 sd">4,347</td>
<td class="gt_row gt_right" headers="stub-2 skewness">2.8293</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">P4.13</th>
<td class="gt_row gt_right" headers="stub-3 mean">6,000</td>
<td class="gt_row gt_right" headers="stub-3 sd">5,196</td>
<td class="gt_row gt_right" headers="stub-3 skewness">1.5877</td>
</tr>
</tbody>
</table>


``` python
rows = []
for name, _, lam, shape, scale, S, exact, normal, sgamma in cases:
    m = compound_moments(Poisson(lam), Gamma(shape, scale))
    for i, s in enumerate(S):
        rows.append((f"{name}, s = {s:,}",
                     exact[i], poisson_gamma_cdf(s, lam, shape, scale),
                     normal[i], m.approximate("normal").cdf(s),
                     sgamma[i], m.approximate("shifted_gamma").cdf(s),
                     m.approximate("shifted_lognormal").cdf(s)))
approx = pd.DataFrame(rows, columns=["case", "exact_book", "exact", "normal_book", "normal",
                                     "sgamma_book", "sgamma", "slognormal"])
(GT(approx, rowname_col="case")
 .tab_header("F(s) by the exact series and three approximations")
 .tab_spanner("exact series", ["exact_book", "exact"])
 .tab_spanner("normal approximation", ["normal_book", "normal"])
 .tab_spanner("shifted gamma", ["sgamma_book", "sgamma"])
 .fmt_number(["exact_book", "exact", "normal_book", "normal", "sgamma_book", "sgamma", "slognormal"],
             decimals=4)
 .fmt_number(["exact_book", "exact"], rows=[5], decimals=5)   # Table 4.4 at s = 0
 .cols_label(exact_book="book", exact="prospicio", normal_book="book", normal="prospicio",
             sgamma_book="book", sgamma="prospicio", slognormal="shifted lognormal"))
```


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

#exqqthpcgi thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#exqqthpcgi p { margin: 0; padding: 0; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #exqqthpcgi .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; }
 #exqqthpcgi .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; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #exqqthpcgi .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; }
 #exqqthpcgi .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; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_column_spanner_outer:first-child { padding-left: 0; }
 #exqqthpcgi .gt_column_spanner_outer:last-child { padding-right: 0; }
 #exqqthpcgi .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%; }
 #exqqthpcgi .gt_spanner_row { border-bottom-style: hidden; }
 #exqqthpcgi .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; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_from_md> :first-child { margin-top: 0; }
 #exqqthpcgi .gt_from_md> :last-child { margin-bottom: 0; }
 #exqqthpcgi .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; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_indent_1 { text-indent: 5px; }
 #exqqthpcgi .gt_indent_2 { text-indent: calc(5px * 2); }
 #exqqthpcgi .gt_indent_3 { text-indent: calc(5px * 3); }
 #exqqthpcgi .gt_indent_4 { text-indent: calc(5px * 4); }
 #exqqthpcgi .gt_indent_5 { text-indent: calc(5px * 5); }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_row_group_first td { border-top-width: 2px; }
 #exqqthpcgi .gt_row_group_first th { border-top-width: 2px; }
 #exqqthpcgi .gt_striped { color: #333333; background-color: #F4F4F4; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #exqqthpcgi .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #exqqthpcgi .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #exqqthpcgi .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #exqqthpcgi .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #exqqthpcgi .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #exqqthpcgi .gt_left { text-align: left; }
 #exqqthpcgi .gt_center { text-align: center; }
 #exqqthpcgi .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #exqqthpcgi .gt_font_normal { font-weight: normal; }
 #exqqthpcgi .gt_font_bold { font-weight: bold; }
 #exqqthpcgi .gt_font_italic { font-style: italic; }
 #exqqthpcgi .gt_super { font-size: 65%; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #exqqthpcgi .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; }
 #exqqthpcgi .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #exqqthpcgi .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #exqqthpcgi .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_heading">
<th colspan="8" id="title" class="gt_heading gt_title gt_font_normal">F(s) by the exact series and three approximations</th>
</tr>
<tr class="gt_col_headings gt_spanner_row">
<th rowspan="2" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th colspan="2" id="exact-series" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">exact series</th>
<th colspan="2" id="normal-approximation" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">normal approximation</th>
<th colspan="2" id="shifted-gamma" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">shifted gamma</th>
<th rowspan="2" id="slognormal" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">shifted lognormal</th>
</tr>
<tr class="gt_col_headings">
<th id="exact_book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="exact" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
<th id="normal_book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="normal" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
<th id="sgamma_book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="sgamma" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Table 4.3, s = 0</th>
<td class="gt_row gt_right" headers="stub-1 exact-series exact_book">0.0821</td>
<td class="gt_row gt_right" headers="stub-1 exact-series exact">0.0821</td>
<td class="gt_row gt_right" headers="stub-1 normal-approximation normal_book">0.0855</td>
<td class="gt_row gt_right" headers="stub-1 normal-approximation normal">0.0855</td>
<td class="gt_row gt_right" headers="stub-1 shifted-gamma sgamma_book">0.0459</td>
<td class="gt_row gt_right" headers="stub-1 shifted-gamma sgamma">0.0459</td>
<td class="gt_row gt_right" headers="stub-1 slognormal">0.0497</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Table 4.3, s = 2,000</th>
<td class="gt_row gt_right" headers="stub-2 exact-series exact_book">0.3755</td>
<td class="gt_row gt_right" headers="stub-2 exact-series exact">0.3755</td>
<td class="gt_row gt_right" headers="stub-2 normal-approximation normal_book">0.3240</td>
<td class="gt_row gt_right" headers="stub-2 normal-approximation normal">0.3240</td>
<td class="gt_row gt_right" headers="stub-2 shifted-gamma sgamma_book">0.3680</td>
<td class="gt_row gt_right" headers="stub-2 shifted-gamma sgamma">0.3680</td>
<td class="gt_row gt_right" headers="stub-2 slognormal">0.3609</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Table 4.3, s = 4,000</th>
<td class="gt_row gt_right" headers="stub-3 exact-series exact_book">0.7152</td>
<td class="gt_row gt_right" headers="stub-3 exact-series exact">0.7152</td>
<td class="gt_row gt_right" headers="stub-3 normal-approximation normal_book">0.6760</td>
<td class="gt_row gt_right" headers="stub-3 normal-approximation normal">0.6760</td>
<td class="gt_row gt_right" headers="stub-3 shifted-gamma sgamma_book">0.7185</td>
<td class="gt_row gt_right" headers="stub-3 shifted-gamma sgamma">0.7185</td>
<td class="gt_row gt_right" headers="stub-3 slognormal">0.7197</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">Table 4.3, s = 6,000</th>
<td class="gt_row gt_right" headers="stub-4 exact-series exact_book">0.9013</td>
<td class="gt_row gt_right" headers="stub-4 exact-series exact">0.9013</td>
<td class="gt_row gt_right" headers="stub-4 normal-approximation normal_book">0.9145</td>
<td class="gt_row gt_right" headers="stub-4 normal-approximation normal">0.9145</td>
<td class="gt_row gt_right" headers="stub-4 shifted-gamma sgamma_book">0.9038</td>
<td class="gt_row gt_right" headers="stub-4 shifted-gamma sgamma">0.9038</td>
<td class="gt_row gt_right" headers="stub-4 slognormal">0.9064</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">Table 4.3, s = 8,000</th>
<td class="gt_row gt_right" headers="stub-5 exact-series exact_book">0.9723</td>
<td class="gt_row gt_right" headers="stub-5 exact-series exact">0.9723</td>
<td class="gt_row gt_right" headers="stub-5 normal-approximation normal_book">0.9888</td>
<td class="gt_row gt_right" headers="stub-5 normal-approximation normal">0.9888</td>
<td class="gt_row gt_right" headers="stub-5 shifted-gamma sgamma_book">0.9724</td>
<td class="gt_row gt_right" headers="stub-5 shifted-gamma sgamma">0.9724</td>
<td class="gt_row gt_right" headers="stub-5 slognormal">0.9729</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">Table 4.4, s = 0</th>
<td class="gt_row gt_right" headers="stub-6 exact-series exact_book">0.00005</td>
<td class="gt_row gt_right" headers="stub-6 exact-series exact">0.00005</td>
<td class="gt_row gt_right" headers="stub-6 normal-approximation normal_book">0.2451</td>
<td class="gt_row gt_right" headers="stub-6 normal-approximation normal">0.2451</td>
<td class="gt_row gt_right" headers="stub-6 shifted-gamma sgamma_book">0.1228</td>
<td class="gt_row gt_right" headers="stub-6 shifted-gamma sgamma">0.1228</td>
<td class="gt_row gt_right" headers="stub-6 slognormal">0.2182</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">Table 4.4, s = 2,000</th>
<td class="gt_row gt_right" headers="stub-7 exact-series exact_book">0.5922</td>
<td class="gt_row gt_right" headers="stub-7 exact-series exact">0.5922</td>
<td class="gt_row gt_right" headers="stub-7 normal-approximation normal_book">0.4090</td>
<td class="gt_row gt_right" headers="stub-7 normal-approximation normal">0.4090</td>
<td class="gt_row gt_right" headers="stub-7 shifted-gamma sgamma_book">0.5886</td>
<td class="gt_row gt_right" headers="stub-7 shifted-gamma sgamma">0.5886</td>
<td class="gt_row gt_right" headers="stub-7 slognormal">0.5234</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">Table 4.4, s = 6,000</th>
<td class="gt_row gt_right" headers="stub-8 exact-series exact_book">0.8401</td>
<td class="gt_row gt_right" headers="stub-8 exact-series exact">0.8401</td>
<td class="gt_row gt_right" headers="stub-8 normal-approximation normal_book">0.7549</td>
<td class="gt_row gt_right" headers="stub-8 normal-approximation normal">0.7549</td>
<td class="gt_row gt_right" headers="stub-8 shifted-gamma sgamma_book">0.8402</td>
<td class="gt_row gt_right" headers="stub-8 shifted-gamma sgamma">0.8402</td>
<td class="gt_row gt_right" headers="stub-8 slognormal">0.8341</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">Table 4.4, s = 10,000</th>
<td class="gt_row gt_right" headers="stub-9 exact-series exact_book">0.9294</td>
<td class="gt_row gt_right" headers="stub-9 exact-series exact">0.9294</td>
<td class="gt_row gt_right" headers="stub-9 normal-approximation normal_book">0.9463</td>
<td class="gt_row gt_right" headers="stub-9 normal-approximation normal">0.9463</td>
<td class="gt_row gt_right" headers="stub-9 shifted-gamma sgamma_book">0.9298</td>
<td class="gt_row gt_right" headers="stub-9 shifted-gamma sgamma">0.9298</td>
<td class="gt_row gt_right" headers="stub-9 slognormal">0.9364</td>
</tr>
<tr>
<th id="stub-10" class="gt_row gt_left gt_stub" scope="row">Table 4.4, s = 18,000</th>
<td class="gt_row gt_right" headers="stub-10 exact-series exact_book">0.9846</td>
<td class="gt_row gt_right" headers="stub-10 exact-series exact">0.9846</td>
<td class="gt_row gt_right" headers="stub-10 normal-approximation normal_book">0.9997</td>
<td class="gt_row gt_right" headers="stub-10 normal-approximation normal">0.9997</td>
<td class="gt_row gt_right" headers="stub-10 shifted-gamma sgamma_book">0.9847</td>
<td class="gt_row gt_right" headers="stub-10 shifted-gamma sgamma">0.9847</td>
<td class="gt_row gt_right" headers="stub-10 slognormal">0.9874</td>
</tr>
<tr>
<th id="stub-11" class="gt_row gt_left gt_stub" scope="row">P4.13, s = 0</th>
<td class="gt_row gt_right" headers="stub-11 exact-series exact_book">0.0003</td>
<td class="gt_row gt_right" headers="stub-11 exact-series exact">0.0003</td>
<td class="gt_row gt_right" headers="stub-11 normal-approximation normal_book">0.1241</td>
<td class="gt_row gt_right" headers="stub-11 normal-approximation normal">0.1241</td>
<td class="gt_row gt_right" headers="stub-11 shifted-gamma sgamma_book">0.0263</td>
<td class="gt_row gt_right" headers="stub-11 shifted-gamma sgamma">0.0263</td>
<td class="gt_row gt_right" headers="stub-11 slognormal">0.0586</td>
</tr>
<tr>
<th id="stub-12" class="gt_row gt_left gt_stub" scope="row">P4.13, s = 3,000</th>
<td class="gt_row gt_right" headers="stub-12 exact-series exact_book">0.3420</td>
<td class="gt_row gt_right" headers="stub-12 exact-series exact">0.3420</td>
<td class="gt_row gt_right" headers="stub-12 normal-approximation normal_book">0.2819</td>
<td class="gt_row gt_right" headers="stub-12 normal-approximation normal">0.2819</td>
<td class="gt_row gt_right" headers="stub-12 shifted-gamma sgamma_book">0.3362</td>
<td class="gt_row gt_right" headers="stub-12 shifted-gamma sgamma">0.3362</td>
<td class="gt_row gt_right" headers="stub-12 slognormal">0.3139</td>
</tr>
<tr>
<th id="stub-13" class="gt_row gt_left gt_stub" scope="row">P4.13, s = 9,000</th>
<td class="gt_row gt_right" headers="stub-13 exact-series exact_book">0.7774</td>
<td class="gt_row gt_right" headers="stub-13 exact-series exact">0.7774</td>
<td class="gt_row gt_right" headers="stub-13 normal-approximation normal_book">0.7181</td>
<td class="gt_row gt_right" headers="stub-13 normal-approximation normal">0.7181</td>
<td class="gt_row gt_right" headers="stub-13 shifted-gamma sgamma_book">0.7782</td>
<td class="gt_row gt_right" headers="stub-13 shifted-gamma sgamma">0.7782</td>
<td class="gt_row gt_right" headers="stub-13 slognormal">0.7790</td>
</tr>
<tr>
<th id="stub-14" class="gt_row gt_left gt_stub" scope="row">P4.13, s = 15,000</th>
<td class="gt_row gt_right" headers="stub-14 exact-series exact_book">0.9349</td>
<td class="gt_row gt_right" headers="stub-14 exact-series exact">0.9349</td>
<td class="gt_row gt_right" headers="stub-14 normal-approximation normal_book">0.9584</td>
<td class="gt_row gt_right" headers="stub-14 normal-approximation normal">0.9584</td>
<td class="gt_row gt_right" headers="stub-14 shifted-gamma sgamma_book">0.9356</td>
<td class="gt_row gt_right" headers="stub-14 shifted-gamma sgamma">0.9356</td>
<td class="gt_row gt_right" headers="stub-14 slognormal">0.9402</td>
</tr>
<tr>
<th id="stub-15" class="gt_row gt_left gt_stub" scope="row">P4.13, s = 27,000</th>
<td class="gt_row gt_right" headers="stub-15 exact-series exact_book">0.9954</td>
<td class="gt_row gt_right" headers="stub-15 exact-series exact">0.9954</td>
<td class="gt_row gt_right" headers="stub-15 normal-approximation normal_book">1.0000</td>
<td class="gt_row gt_right" headers="stub-15 normal-approximation normal">1.0000</td>
<td class="gt_row gt_right" headers="stub-15 shifted-gamma sgamma_book">0.9953</td>
<td class="gt_row gt_right" headers="stub-15 shifted-gamma sgamma">0.9953</td>
<td class="gt_row gt_right" headers="stub-15 slognormal">0.9951</td>
</tr>
</tbody>
</table>


The normal leaves the exact curve at both ends. The shifted gamma stays on it except near zero:


``` python
fig, axes = plt.subplots(1, 2, figsize=(8.0, 3.6), sharey=True)
for ax, (name, _, lam, shape, scale, *_rest) in zip(axes, cases[:2]):
    m = compound_moments(Poisson(lam), Gamma(shape, scale))
    top = m.mean + 4.5 * m.variance ** 0.5
    xs = [top * i / 40 for i in range(41)]
    ax.plot(xs, [poisson_gamma_cdf(x, lam, shape, scale, terms=60) for x in xs],
            color="0.75", linewidth=4, label="exact")
    ax.plot(xs, [m.approximate("normal").cdf(x) for x in xs], label="normal")
    ax.plot(xs, [m.approximate("shifted_gamma").cdf(x) for x in xs], label="shifted gamma")
    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fails near zero, where it has no mass for the chance of no claim. The normal misses the right tail by several percent. For capital or stop-loss questions use the exact distribution (next section), which is cheap.


# 7. Recursion and Fourier inversion

**Panjer's recursion** is exact for claim sizes on a grid and a Poisson, negative binomial or binomial count. Ex 4.4 has a Poisson 1.75 and sizes of 1,000 to 5,000:


``` python
size = Grid(1000.0, [0.0, 0.20, 0.40, 0.20, 0.15, 0.05])
agg, _ = panjer(Poisson(1.75), size, 64)
book = [0.1738, 0.0608, 0.1323, 0.1046, 0.117, 0.0932, 0.0786, 0.0641]
rows = [(f"Ex 4.4, f_S({1000 * k:,})", b, agg.probs[k]) for k, b in enumerate(book)]
rows += [(f"Ex 4.4, F_S({s:,})", b, agg.cdf(float(s)))
         for s, b in [(9000, 0.9121), (12000, 0.9729), (16000, 0.9955)]]
compare(rows, "Ex 4.4: Panjer's recursion, a Poisson 1.75")
```


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

#bfejnnuohe thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#bfejnnuohe p { margin: 0; padding: 0; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #bfejnnuohe .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; }
 #bfejnnuohe .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; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #bfejnnuohe .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; }
 #bfejnnuohe .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; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_column_spanner_outer:first-child { padding-left: 0; }
 #bfejnnuohe .gt_column_spanner_outer:last-child { padding-right: 0; }
 #bfejnnuohe .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%; }
 #bfejnnuohe .gt_spanner_row { border-bottom-style: hidden; }
 #bfejnnuohe .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; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_from_md> :first-child { margin-top: 0; }
 #bfejnnuohe .gt_from_md> :last-child { margin-bottom: 0; }
 #bfejnnuohe .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; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_indent_1 { text-indent: 5px; }
 #bfejnnuohe .gt_indent_2 { text-indent: calc(5px * 2); }
 #bfejnnuohe .gt_indent_3 { text-indent: calc(5px * 3); }
 #bfejnnuohe .gt_indent_4 { text-indent: calc(5px * 4); }
 #bfejnnuohe .gt_indent_5 { text-indent: calc(5px * 5); }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_row_group_first td { border-top-width: 2px; }
 #bfejnnuohe .gt_row_group_first th { border-top-width: 2px; }
 #bfejnnuohe .gt_striped { color: #333333; background-color: #F4F4F4; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #bfejnnuohe .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #bfejnnuohe .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #bfejnnuohe .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #bfejnnuohe .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #bfejnnuohe .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #bfejnnuohe .gt_left { text-align: left; }
 #bfejnnuohe .gt_center { text-align: center; }
 #bfejnnuohe .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #bfejnnuohe .gt_font_normal { font-weight: normal; }
 #bfejnnuohe .gt_font_bold { font-weight: bold; }
 #bfejnnuohe .gt_font_italic { font-style: italic; }
 #bfejnnuohe .gt_super { font-size: 65%; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #bfejnnuohe .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; }
 #bfejnnuohe .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #bfejnnuohe .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #bfejnnuohe .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 4.4: Panjer's recursion, a Poisson 1.75</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, f_S(0)</th>
<td class="gt_row gt_right" headers="stub-1 book">0.1738</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.1738</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, f_S(1,000)</th>
<td class="gt_row gt_right" headers="stub-2 book">0.0608</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.0608</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, f_S(2,000)</th>
<td class="gt_row gt_right" headers="stub-3 book">0.1323</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.1323</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, f_S(3,000)</th>
<td class="gt_row gt_right" headers="stub-4 book">0.1046</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.1046</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, f_S(4,000)</th>
<td class="gt_row gt_right" headers="stub-5 book">0.1170</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.1170</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, f_S(5,000)</th>
<td class="gt_row gt_right" headers="stub-6 book">0.0932</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.0932</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, f_S(6,000)</th>
<td class="gt_row gt_right" headers="stub-7 book">0.0786</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.0786</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, f_S(7,000)</th>
<td class="gt_row gt_right" headers="stub-8 book">0.0641</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.0641</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, F_S(9,000)</th>
<td class="gt_row gt_right" headers="stub-9 book">0.9121</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">0.9121</td>
</tr>
<tr>
<th id="stub-10" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, F_S(12,000)</th>
<td class="gt_row gt_right" headers="stub-10 book">0.9729</td>
<td class="gt_row gt_right" headers="stub-10 prospicio">0.9729</td>
</tr>
<tr>
<th id="stub-11" class="gt_row gt_left gt_stub" scope="row">Ex 4.4, F_S(16,000)</th>
<td class="gt_row gt_right" headers="stub-11 book">0.9955</td>
<td class="gt_row gt_right" headers="stub-11 prospicio">0.9955</td>
</tr>
</tbody>
</table>


A continuous severity goes on a grid first. The **midpoint** method gives each point the probability of its interval ([Grid.rounding](../reference/distributions.Grid.md#prospicio.distributions.Grid.rounding)). Ex 4.5 does this to the gamma of Ex 4.2 with steps of 100 and 20. The finer step brings the recursion within about 1% of the exact values at small totals, and closer above:


``` python
S = [500, 1000, 2000, 4000, 6000, 10000]
ex_45 = {}
for h, book in [(100.0, [0.1158, 0.1956, 0.3852, 0.7218, 0.9042, 0.9937]),
                (20.0, [0.1108, 0.1885, 0.3775, 0.7165, 0.9019, 0.9935])]:
    grid, _ = Grid.rounding(Gamma(3.0, 400.0), h, int(6000 / h) + 1)
    agg, _ = panjer(Poisson(2.5), grid, int(30000 / h))
    ex_45[h] = (book, [agg.cdf(s) for s in S])
    print(f"Ex 4.5  step {h:3.0f}  grid mean {grid.mean():,.2f}  variance {grid.variance():,.0f}")
```


    Ex 4.5  step 100  grid mean 1,199.98  variance 480,642
    Ex 4.5  step  20  grid mean 1,199.98  variance 479,846


``` python
(GT(pd.DataFrame({"s": [f"F_S({s:,})" for s in S],
                  "book_100": ex_45[100.0][0], "ours_100": ex_45[100.0][1],
                  "book_20": ex_45[20.0][0], "ours_20": ex_45[20.0][1]}), rowname_col="s")
 .tab_header("Ex 4.5: Panjer's recursion on the midpoint grid")
 .tab_spanner("step 100", ["book_100", "ours_100"])
 .tab_spanner("step 20", ["book_20", "ours_20"])
 .fmt_number(["book_100", "ours_100", "book_20", "ours_20"], decimals=4)
 .cols_label(book_100="book", ours_100="prospicio", book_20="book", ours_20="prospicio"))
```


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

#rvikgjgsnz thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#rvikgjgsnz p { margin: 0; padding: 0; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_column_spanner_outer:first-child { padding-left: 0; }
 #rvikgjgsnz .gt_column_spanner_outer:last-child { padding-right: 0; }
 #rvikgjgsnz .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%; }
 #rvikgjgsnz .gt_spanner_row { border-bottom-style: hidden; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_from_md> :first-child { margin-top: 0; }
 #rvikgjgsnz .gt_from_md> :last-child { margin-bottom: 0; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_indent_1 { text-indent: 5px; }
 #rvikgjgsnz .gt_indent_2 { text-indent: calc(5px * 2); }
 #rvikgjgsnz .gt_indent_3 { text-indent: calc(5px * 3); }
 #rvikgjgsnz .gt_indent_4 { text-indent: calc(5px * 4); }
 #rvikgjgsnz .gt_indent_5 { text-indent: calc(5px * 5); }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_row_group_first td { border-top-width: 2px; }
 #rvikgjgsnz .gt_row_group_first th { border-top-width: 2px; }
 #rvikgjgsnz .gt_striped { color: #333333; background-color: #F4F4F4; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #rvikgjgsnz .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #rvikgjgsnz .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #rvikgjgsnz .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #rvikgjgsnz .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #rvikgjgsnz .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #rvikgjgsnz .gt_left { text-align: left; }
 #rvikgjgsnz .gt_center { text-align: center; }
 #rvikgjgsnz .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #rvikgjgsnz .gt_font_normal { font-weight: normal; }
 #rvikgjgsnz .gt_font_bold { font-weight: bold; }
 #rvikgjgsnz .gt_font_italic { font-style: italic; }
 #rvikgjgsnz .gt_super { font-size: 65%; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #rvikgjgsnz .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; }
 #rvikgjgsnz .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #rvikgjgsnz .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #rvikgjgsnz .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 4.5: Panjer's recursion on the midpoint grid</th>
</tr>
<tr class="gt_col_headings gt_spanner_row">
<th rowspan="2" class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th colspan="2" id="step-100" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">step 100</th>
<th colspan="2" id="step-20" class="gt_center gt_columns_top_border gt_column_spanner_outer" scope="colgroup">step 20</th>
</tr>
<tr class="gt_col_headings">
<th id="book_100" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="ours_100" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
<th id="book_20" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="ours_20" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">F_S(500)</th>
<td class="gt_row gt_right" headers="stub-1 step-100 book_100">0.1158</td>
<td class="gt_row gt_right" headers="stub-1 step-100 ours_100">0.1158</td>
<td class="gt_row gt_right" headers="stub-1 step-20 book_20">0.1108</td>
<td class="gt_row gt_right" headers="stub-1 step-20 ours_20">0.1108</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">F_S(1,000)</th>
<td class="gt_row gt_right" headers="stub-2 step-100 book_100">0.1956</td>
<td class="gt_row gt_right" headers="stub-2 step-100 ours_100">0.1956</td>
<td class="gt_row gt_right" headers="stub-2 step-20 book_20">0.1885</td>
<td class="gt_row gt_right" headers="stub-2 step-20 ours_20">0.1885</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">F_S(2,000)</th>
<td class="gt_row gt_right" headers="stub-3 step-100 book_100">0.3852</td>
<td class="gt_row gt_right" headers="stub-3 step-100 ours_100">0.3852</td>
<td class="gt_row gt_right" headers="stub-3 step-20 book_20">0.3775</td>
<td class="gt_row gt_right" headers="stub-3 step-20 ours_20">0.3775</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">F_S(4,000)</th>
<td class="gt_row gt_right" headers="stub-4 step-100 book_100">0.7218</td>
<td class="gt_row gt_right" headers="stub-4 step-100 ours_100">0.7218</td>
<td class="gt_row gt_right" headers="stub-4 step-20 book_20">0.7165</td>
<td class="gt_row gt_right" headers="stub-4 step-20 ours_20">0.7165</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">F_S(6,000)</th>
<td class="gt_row gt_right" headers="stub-5 step-100 book_100">0.9042</td>
<td class="gt_row gt_right" headers="stub-5 step-100 ours_100">0.9042</td>
<td class="gt_row gt_right" headers="stub-5 step-20 book_20">0.9019</td>
<td class="gt_row gt_right" headers="stub-5 step-20 ours_20">0.9019</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">F_S(10,000)</th>
<td class="gt_row gt_right" headers="stub-6 step-100 book_100">0.9937</td>
<td class="gt_row gt_right" headers="stub-6 step-100 ours_100">0.9937</td>
<td class="gt_row gt_right" headers="stub-6 step-20 book_20">0.9935</td>
<td class="gt_row gt_right" headers="stub-6 step-20 ours_20">0.9935</td>
</tr>
</tbody>
</table>


Every figure agrees, and so do the printed grid moments (1,199.98 and 480,642 for the step of 100, 479,846 for 20), except the mean for the step of 20: the monograph prints 1,199.88, a slipped digit. P4.16 recurses a Poisson 1.35 on the sizes of P4.1:


``` python
agg, _ = panjer(Poisson(1.35), Grid(500.0, [0.0, 0.1, 0.4, 0.3, 0.2]), 64)
book = [0.2592, 0.2942, 0.4366, 0.5606, 0.6838, 0.8306, 0.9223, 0.967, 0.9872]
at = (0, 500, 1000, 1500, 2000, 3000, 4000, 5000, 6000)
compare([(f"P4.16, F_S({s:,})", b, agg.cdf(float(s))) for s, b in zip(at, book)],
        "P4.16: Panjer's recursion, a Poisson 1.35")
```


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

#gebsbozoli thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#gebsbozoli p { margin: 0; padding: 0; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #gebsbozoli .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; }
 #gebsbozoli .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; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #gebsbozoli .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; }
 #gebsbozoli .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; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_column_spanner_outer:first-child { padding-left: 0; }
 #gebsbozoli .gt_column_spanner_outer:last-child { padding-right: 0; }
 #gebsbozoli .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%; }
 #gebsbozoli .gt_spanner_row { border-bottom-style: hidden; }
 #gebsbozoli .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; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_from_md> :first-child { margin-top: 0; }
 #gebsbozoli .gt_from_md> :last-child { margin-bottom: 0; }
 #gebsbozoli .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; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_indent_1 { text-indent: 5px; }
 #gebsbozoli .gt_indent_2 { text-indent: calc(5px * 2); }
 #gebsbozoli .gt_indent_3 { text-indent: calc(5px * 3); }
 #gebsbozoli .gt_indent_4 { text-indent: calc(5px * 4); }
 #gebsbozoli .gt_indent_5 { text-indent: calc(5px * 5); }
 #gebsbozoli .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; }
 #gebsbozoli .gt_row_group_first td { border-top-width: 2px; }
 #gebsbozoli .gt_row_group_first th { border-top-width: 2px; }
 #gebsbozoli .gt_striped { color: #333333; background-color: #F4F4F4; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #gebsbozoli .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #gebsbozoli .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #gebsbozoli .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #gebsbozoli .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #gebsbozoli .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #gebsbozoli .gt_left { text-align: left; }
 #gebsbozoli .gt_center { text-align: center; }
 #gebsbozoli .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #gebsbozoli .gt_font_normal { font-weight: normal; }
 #gebsbozoli .gt_font_bold { font-weight: bold; }
 #gebsbozoli .gt_font_italic { font-style: italic; }
 #gebsbozoli .gt_super { font-size: 65%; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #gebsbozoli .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; }
 #gebsbozoli .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #gebsbozoli .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #gebsbozoli .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">P4.16: Panjer's recursion, a Poisson 1.35</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(0)</th>
<td class="gt_row gt_right" headers="stub-1 book">0.2592</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.2592</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(500)</th>
<td class="gt_row gt_right" headers="stub-2 book">0.2942</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.2942</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(1,000)</th>
<td class="gt_row gt_right" headers="stub-3 book">0.4366</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.4366</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(1,500)</th>
<td class="gt_row gt_right" headers="stub-4 book">0.5606</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.5606</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(2,000)</th>
<td class="gt_row gt_right" headers="stub-5 book">0.6838</td>
<td class="gt_row gt_right" headers="stub-5 prospicio">0.6838</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(3,000)</th>
<td class="gt_row gt_right" headers="stub-6 book">0.8306</td>
<td class="gt_row gt_right" headers="stub-6 prospicio">0.8306</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(4,000)</th>
<td class="gt_row gt_right" headers="stub-7 book">0.9223</td>
<td class="gt_row gt_right" headers="stub-7 prospicio">0.9223</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(5,000)</th>
<td class="gt_row gt_right" headers="stub-8 book">0.9670</td>
<td class="gt_row gt_right" headers="stub-8 prospicio">0.9670</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">P4.16, F_S(6,000)</th>
<td class="gt_row gt_right" headers="stub-9 book">0.9872</td>
<td class="gt_row gt_right" headers="stub-9 prospicio">0.9872</td>
</tr>
</tbody>
</table>


The monograph's **Fourier** method (Ex 4.7) is Heckman and Meyers' inversion of the characteristic function. prospicio inverts with the FFT on a grid ([fft](../reference/aggregate.fft.md#prospicio.aggregate.fft), or [fft_auto](../reference/aggregate.fft_auto.md#prospicio.aggregate.fft_auto), which picks the grid). It takes any count prospicio supports, and counts much larger than the recursion allows, since e^(−λ) underflows for large λ. On Ex 4.2 with a step of 1, a mean-preserving grid ([Grid.local_moment](../reference/distributions.Grid.md#prospicio.distributions.Grid.local_moment)) and 2^16 points, it reproduces the exact series:


``` python
grid, _ = Grid.local_moment(Gamma(3.0, 400.0), 1.0, 20001)
agg, report = fft(Poisson(2.5), grid, 2**16)
S = [500, 1000, 2000, 3000, 4000, 6000, 8000, 10000]
print(f"Ex 4.7  aliasing error below 1e-12: {report.aliasing_error < 1e-12}")
```


    Ex 4.7  aliasing error below 1e-12: True


``` python
book = [0.1094, 0.1869, 0.3757, 0.5614, 0.7151, 0.9011, 0.9722, 0.9934]
ex_47 = pd.DataFrame({"s": [f"F_S({s:,})" for s in S], "book": book,
                      "exact": [poisson_gamma_cdf(s, 2.5, 3.0, 400.0) for s in S],
                      "fft": [agg.cdf(s) for s in S]})
(GT(ex_47, rowname_col="s")
 .tab_header("Ex 4.7: Heckman and Meyers against the exact series and the FFT")
 .fmt_number(["book", "exact", "fft"], decimals=4)
 .cols_label(exact="exact series", fft="FFT, prospicio"))
```


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

#rwlzbbmhou thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#rwlzbbmhou p { margin: 0; padding: 0; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_column_spanner_outer:first-child { padding-left: 0; }
 #rwlzbbmhou .gt_column_spanner_outer:last-child { padding-right: 0; }
 #rwlzbbmhou .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%; }
 #rwlzbbmhou .gt_spanner_row { border-bottom-style: hidden; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_from_md> :first-child { margin-top: 0; }
 #rwlzbbmhou .gt_from_md> :last-child { margin-bottom: 0; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_indent_1 { text-indent: 5px; }
 #rwlzbbmhou .gt_indent_2 { text-indent: calc(5px * 2); }
 #rwlzbbmhou .gt_indent_3 { text-indent: calc(5px * 3); }
 #rwlzbbmhou .gt_indent_4 { text-indent: calc(5px * 4); }
 #rwlzbbmhou .gt_indent_5 { text-indent: calc(5px * 5); }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_row_group_first td { border-top-width: 2px; }
 #rwlzbbmhou .gt_row_group_first th { border-top-width: 2px; }
 #rwlzbbmhou .gt_striped { color: #333333; background-color: #F4F4F4; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #rwlzbbmhou .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #rwlzbbmhou .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #rwlzbbmhou .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #rwlzbbmhou .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #rwlzbbmhou .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #rwlzbbmhou .gt_left { text-align: left; }
 #rwlzbbmhou .gt_center { text-align: center; }
 #rwlzbbmhou .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #rwlzbbmhou .gt_font_normal { font-weight: normal; }
 #rwlzbbmhou .gt_font_bold { font-weight: bold; }
 #rwlzbbmhou .gt_font_italic { font-style: italic; }
 #rwlzbbmhou .gt_super { font-size: 65%; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #rwlzbbmhou .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; }
 #rwlzbbmhou .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #rwlzbbmhou .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #rwlzbbmhou .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 4.7: Heckman and Meyers against the exact series and the FFT</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="exact" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">exact series</th>
<th id="fft" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">FFT, prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">F_S(500)</th>
<td class="gt_row gt_right" headers="stub-1 book">0.1094</td>
<td class="gt_row gt_right" headers="stub-1 exact">0.1096</td>
<td class="gt_row gt_right" headers="stub-1 fft">0.1096</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">F_S(1,000)</th>
<td class="gt_row gt_right" headers="stub-2 book">0.1869</td>
<td class="gt_row gt_right" headers="stub-2 exact">0.1867</td>
<td class="gt_row gt_right" headers="stub-2 fft">0.1868</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">F_S(2,000)</th>
<td class="gt_row gt_right" headers="stub-3 book">0.3757</td>
<td class="gt_row gt_right" headers="stub-3 exact">0.3755</td>
<td class="gt_row gt_right" headers="stub-3 fft">0.3756</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">F_S(3,000)</th>
<td class="gt_row gt_right" headers="stub-4 book">0.5614</td>
<td class="gt_row gt_right" headers="stub-4 exact">0.5613</td>
<td class="gt_row gt_right" headers="stub-4 fft">0.5614</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">F_S(4,000)</th>
<td class="gt_row gt_right" headers="stub-5 book">0.7151</td>
<td class="gt_row gt_right" headers="stub-5 exact">0.7152</td>
<td class="gt_row gt_right" headers="stub-5 fft">0.7152</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">F_S(6,000)</th>
<td class="gt_row gt_right" headers="stub-6 book">0.9011</td>
<td class="gt_row gt_right" headers="stub-6 exact">0.9013</td>
<td class="gt_row gt_right" headers="stub-6 fft">0.9014</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">F_S(8,000)</th>
<td class="gt_row gt_right" headers="stub-7 book">0.9722</td>
<td class="gt_row gt_right" headers="stub-7 exact">0.9723</td>
<td class="gt_row gt_right" headers="stub-7 fft">0.9723</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">F_S(10,000)</th>
<td class="gt_row gt_right" headers="stub-8 book">0.9934</td>
<td class="gt_row gt_right" headers="stub-8 exact">0.9934</td>
<td class="gt_row gt_right" headers="stub-8 fft">0.9934</td>
</tr>
</tbody>
</table>


The FFT is within a unit in the fourth decimal (the grid's half-step), the same accuracy as Heckman and Meyers' method.

A per-claim limit puts a mass in the severity, so the aggregate jumps at multiples of the limit. Ex 4.8 caps gamma (2.5; 500) claims at 2,000 under a Poisson 1.308. The jump at 2,000 is Pr{N = 1} Pr{X \> 2,000}:


``` python
size = Gamma(2.5, 500.0)
compare([("Ex 4.8, E[X; 2,000]", 1_147, size.lev(2000.0), 0),
         ("Ex 4.8, mass at the limit", 0.1562, size.survival(2000.0)),
         ("Ex 4.8, jump in F_S at 2,000", 0.0552, Poisson(1.308).pmf(1) * size.survival(2000.0))],
        "Ex 4.8: a per-claim limit of 2,000")
```


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

#etdjaeowzm thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#etdjaeowzm p { margin: 0; padding: 0; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #etdjaeowzm .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; }
 #etdjaeowzm .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; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #etdjaeowzm .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; }
 #etdjaeowzm .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; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_column_spanner_outer:first-child { padding-left: 0; }
 #etdjaeowzm .gt_column_spanner_outer:last-child { padding-right: 0; }
 #etdjaeowzm .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%; }
 #etdjaeowzm .gt_spanner_row { border-bottom-style: hidden; }
 #etdjaeowzm .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; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_from_md> :first-child { margin-top: 0; }
 #etdjaeowzm .gt_from_md> :last-child { margin-bottom: 0; }
 #etdjaeowzm .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; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_indent_1 { text-indent: 5px; }
 #etdjaeowzm .gt_indent_2 { text-indent: calc(5px * 2); }
 #etdjaeowzm .gt_indent_3 { text-indent: calc(5px * 3); }
 #etdjaeowzm .gt_indent_4 { text-indent: calc(5px * 4); }
 #etdjaeowzm .gt_indent_5 { text-indent: calc(5px * 5); }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_row_group_first td { border-top-width: 2px; }
 #etdjaeowzm .gt_row_group_first th { border-top-width: 2px; }
 #etdjaeowzm .gt_striped { color: #333333; background-color: #F4F4F4; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #etdjaeowzm .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #etdjaeowzm .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #etdjaeowzm .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #etdjaeowzm .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #etdjaeowzm .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #etdjaeowzm .gt_left { text-align: left; }
 #etdjaeowzm .gt_center { text-align: center; }
 #etdjaeowzm .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #etdjaeowzm .gt_font_normal { font-weight: normal; }
 #etdjaeowzm .gt_font_bold { font-weight: bold; }
 #etdjaeowzm .gt_font_italic { font-style: italic; }
 #etdjaeowzm .gt_super { font-size: 65%; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #etdjaeowzm .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; }
 #etdjaeowzm .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #etdjaeowzm .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #etdjaeowzm .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 4.8: a per-claim limit of 2,000</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 4.8, E[X; 2,000]</th>
<td class="gt_row gt_right" headers="stub-1 book">1,147</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">1,147</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 4.8, mass at the limit</th>
<td class="gt_row gt_right" headers="stub-2 book">0.1562</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.1562</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Ex 4.8, jump in F_S at 2,000</th>
<td class="gt_row gt_right" headers="stub-3 book">0.0552</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.0552</td>
</tr>
</tbody>
</table>


# 8. Simulation

[simulate_events](../reference/aggregate.simulate_events.md#prospicio.aggregate.simulate_events) draws a count, then that many claims, from a seed. Ex 4.14 draws 10,000 years of Ex 4.2. Another generator draws other years, so the check is accuracy, not digits:


``` python
years = simulate_events(Poisson(2.5), Gamma(3.0, 400.0), 10_000, 2015).totals().total()
sim = years.cdf(3000.0)
exact = poisson_gamma_cdf(3000.0, 2.5, 3.0, 400.0)
print(f"Ex 4.14  F(3,000): book's sample 0.5599, exact {exact:.4f}, "
      f"within two standard errors here: {abs(sim - exact) < 2 * math.sqrt(exact * (1 - exact) / 10_000)}")
print(f"Ex 4.13  lognormal (4.956; 2.3), 1.5 claims a year: E[S] = "
      f"{1.5 * Lognormal(4.956, 2.3).mean():,.0f} (book 3,000)")
```


    Ex 4.14  F(3,000): book's sample 0.5599, exact 0.5613, within two standard errors here: True
    Ex 4.13  lognormal (4.956; 2.3), 1.5 claims a year: E[S] = 3,000 (book 3,000)


With 10,000 years the standard error of a probability near one half is 0.005, so a sampled table is good to about two decimals (Table 4.11).


# 9. Aggregate limits

A policy can cap the year's total as well as each claim. The expected loss under a per-claim limit l and an aggregate limit L is E\[S_l; L\]; the increased limit factor is that value over the expected loss at the basic limit. Ex 6.6 has 1.2 expected claims, contagion 0.1 (a negative binomial with r = 10) and lognormal claims with σ = 2.4.

The monograph states μ = 7.000, but its basic-limit loss 1.2 × 21,743 and its 2M loss 1.2 × 28,338 come from μ = 7.6 (μ = 7.0 gives 13,626 and 16,738, the numbers of Ex 6.3). Every figure of Ex 6.6 and Table 6.4 reproduces with 7.6, so 7.000 is a misprint:


``` python
size = Lognormal(7.6, 2.4)
count = claim_count(1.2, 1 + 0.1 * 1.2)
basic = count.mean() * size.lev(500e3)
h = 250.0
capped_2m, _ = Grid.local_moment(size, h, int(2e6 / h) + 1)   # mass at 2M is the cap
m = compound_moments(count, capped_2m)
compare([("Ex 6.6, E[S], 500K per claim", 26_092, basic, 0),
         ("Ex 6.6, E[S], 2M per claim", 34_006, count.mean() * size.lev(2e6), 0),
         ("Ex 6.6, sd of S, 2M per claim", 151_311, m.variance ** 0.5, 0),
         ("Ex 6.6, skewness, 2M per claim", 9.4728, m.skew)],
        "Ex 6.6: lognormal (7.6; 2.4) claims, 1.2 expected claims, contagion 0.1")
```


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

#efqqsqouwa thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#efqqsqouwa p { margin: 0; padding: 0; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #efqqsqouwa .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; }
 #efqqsqouwa .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; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #efqqsqouwa .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; }
 #efqqsqouwa .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; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_column_spanner_outer:first-child { padding-left: 0; }
 #efqqsqouwa .gt_column_spanner_outer:last-child { padding-right: 0; }
 #efqqsqouwa .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%; }
 #efqqsqouwa .gt_spanner_row { border-bottom-style: hidden; }
 #efqqsqouwa .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; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_from_md> :first-child { margin-top: 0; }
 #efqqsqouwa .gt_from_md> :last-child { margin-bottom: 0; }
 #efqqsqouwa .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; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_indent_1 { text-indent: 5px; }
 #efqqsqouwa .gt_indent_2 { text-indent: calc(5px * 2); }
 #efqqsqouwa .gt_indent_3 { text-indent: calc(5px * 3); }
 #efqqsqouwa .gt_indent_4 { text-indent: calc(5px * 4); }
 #efqqsqouwa .gt_indent_5 { text-indent: calc(5px * 5); }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_row_group_first td { border-top-width: 2px; }
 #efqqsqouwa .gt_row_group_first th { border-top-width: 2px; }
 #efqqsqouwa .gt_striped { color: #333333; background-color: #F4F4F4; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #efqqsqouwa .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #efqqsqouwa .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #efqqsqouwa .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #efqqsqouwa .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #efqqsqouwa .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #efqqsqouwa .gt_left { text-align: left; }
 #efqqsqouwa .gt_center { text-align: center; }
 #efqqsqouwa .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #efqqsqouwa .gt_font_normal { font-weight: normal; }
 #efqqsqouwa .gt_font_bold { font-weight: bold; }
 #efqqsqouwa .gt_font_italic { font-style: italic; }
 #efqqsqouwa .gt_super { font-size: 65%; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #efqqsqouwa .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; }
 #efqqsqouwa .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #efqqsqouwa .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #efqqsqouwa .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 6.6: lognormal (7.6; 2.4) claims, 1.2 expected claims, contagion 0.1</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">Ex 6.6, E[S], 500K per claim</th>
<td class="gt_row gt_right" headers="stub-1 book">26,092</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">26,091</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">Ex 6.6, E[S], 2M per claim</th>
<td class="gt_row gt_right" headers="stub-2 book">34,006</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">34,006</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">Ex 6.6, sd of S, 2M per claim</th>
<td class="gt_row gt_right" headers="stub-3 book">151,311</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">151,312</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">Ex 6.6, skewness, 2M per claim</th>
<td class="gt_row gt_right" headers="stub-4 book">9.4728</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">9.4728</td>
</tr>
</tbody>
</table>


The aggregate limit removes E\[(S_l − L)+\]. The monograph takes it from the shifted gamma approximation, whose stop-loss is a gamma's ([Gamma.stop_loss](../reference/distributions.Gamma.md#prospicio.distributions.Gamma.stop_loss) of the unshifted part). The FFT gives it exactly on the same grid:


``` python
def shifted_gamma_excess(moments, L):
    a = dict(moments.approximate("shifted_gamma").parameters)
    return Gamma(a["shape"], a["scale"]).stop_loss(L - a["shift"])


sg = shifted_gamma_excess(m, 3e6)
agg, _ = fft(count, capped_2m, 2**16)
exact = agg.stop_loss(3e6)
removed = pd.DataFrame({
    "row": ["removed by a 3M aggregate limit", "I(2M, 3M)"],
    "book": [91, 1.2998],
    "shifted": [sg, (m.mean - sg) / basic],
    "exact": [exact, (m.mean - exact) / basic],
})
(GT(removed, rowname_col="row")
 .tab_header("Ex 6.6: a 3M aggregate limit on 2M claims")
 .fmt_number(["book", "shifted", "exact"], rows=[0], decimals=0)
 .fmt_number(["book", "shifted", "exact"], rows=[1], decimals=4)
 .cols_label(shifted="shifted gamma", exact="exact, FFT"))
```


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

#mynzmobeee thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#mynzmobeee p { margin: 0; padding: 0; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #mynzmobeee .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; }
 #mynzmobeee .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; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #mynzmobeee .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; }
 #mynzmobeee .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; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_column_spanner_outer:first-child { padding-left: 0; }
 #mynzmobeee .gt_column_spanner_outer:last-child { padding-right: 0; }
 #mynzmobeee .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%; }
 #mynzmobeee .gt_spanner_row { border-bottom-style: hidden; }
 #mynzmobeee .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; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_from_md> :first-child { margin-top: 0; }
 #mynzmobeee .gt_from_md> :last-child { margin-bottom: 0; }
 #mynzmobeee .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; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_indent_1 { text-indent: 5px; }
 #mynzmobeee .gt_indent_2 { text-indent: calc(5px * 2); }
 #mynzmobeee .gt_indent_3 { text-indent: calc(5px * 3); }
 #mynzmobeee .gt_indent_4 { text-indent: calc(5px * 4); }
 #mynzmobeee .gt_indent_5 { text-indent: calc(5px * 5); }
 #mynzmobeee .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; }
 #mynzmobeee .gt_row_group_first td { border-top-width: 2px; }
 #mynzmobeee .gt_row_group_first th { border-top-width: 2px; }
 #mynzmobeee .gt_striped { color: #333333; background-color: #F4F4F4; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #mynzmobeee .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #mynzmobeee .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #mynzmobeee .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #mynzmobeee .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #mynzmobeee .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #mynzmobeee .gt_left { text-align: left; }
 #mynzmobeee .gt_center { text-align: center; }
 #mynzmobeee .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #mynzmobeee .gt_font_normal { font-weight: normal; }
 #mynzmobeee .gt_font_bold { font-weight: bold; }
 #mynzmobeee .gt_font_italic { font-style: italic; }
 #mynzmobeee .gt_super { font-size: 65%; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #mynzmobeee .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; }
 #mynzmobeee .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #mynzmobeee .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #mynzmobeee .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Ex 6.6: a 3M aggregate limit on 2M claims</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="shifted" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">shifted gamma</th>
<th id="exact" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">exact, FFT</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">removed by a 3M aggregate limit</th>
<td class="gt_row gt_right" headers="stub-1 book">91</td>
<td class="gt_row gt_right" headers="stub-1 shifted">91</td>
<td class="gt_row gt_right" headers="stub-1 exact">8</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">I(2M, 3M)</th>
<td class="gt_row gt_right" headers="stub-2 book">1.2998</td>
<td class="gt_row gt_right" headers="stub-2 shifted">1.2999</td>
<td class="gt_row gt_right" headers="stub-2 exact">1.3031</td>
</tr>
</tbody>
</table>


Matched to a skewness of 9.5, the shifted gamma puts far too much probability in the far tail, so it overstates what the limit removes: 91 against 8. The gap grows as the aggregate limit comes down towards the per-claim limit (Table 6.4):


``` python
book = {  # Table 6.4: E[S] by per-claim limit (rows) and aggregate limit
    1e6: {1e6: 29_702, 2e6: 30_306, 3e6: 30_333, 5e6: 30_335},
    2e6: {2e6: 33_524, 3e6: 33_915, 5e6: 34_002},
    3e6: {3e6: 35_421, 5e6: 35_781},
    5e6: {5e6: 37_428},
}
rows, exact_at = [], {}
for l, row in book.items():
    grid, _ = Grid.local_moment(size, h, int(l / h) + 1)
    moments = compound_moments(count, grid)
    agg, _ = fft(count, grid, 2**16)
    for L, value in row.items():
        exact_at[l, L] = agg.lev(L)
        rows.append((f"{l / 1e6:.0f}M per claim, {L / 1e6:.0f}M aggregate",
                     value, moments.mean - shifted_gamma_excess(moments, L), agg.lev(L)))
    exact_at[l, math.inf] = agg.mean()
(GT(pd.DataFrame(rows, columns=["limits", "book", "shifted", "exact"]), rowname_col="limits")
 .tab_header("Table 6.4: E[S] by per-claim and aggregate limit")
 .fmt_number(["book", "shifted", "exact"], decimals=0)
 .cols_label(shifted="shifted gamma", exact="exact, FFT"))
```


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

#vqkqrjxndc thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#vqkqrjxndc p { margin: 0; padding: 0; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_column_spanner_outer:first-child { padding-left: 0; }
 #vqkqrjxndc .gt_column_spanner_outer:last-child { padding-right: 0; }
 #vqkqrjxndc .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%; }
 #vqkqrjxndc .gt_spanner_row { border-bottom-style: hidden; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_from_md> :first-child { margin-top: 0; }
 #vqkqrjxndc .gt_from_md> :last-child { margin-bottom: 0; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_indent_1 { text-indent: 5px; }
 #vqkqrjxndc .gt_indent_2 { text-indent: calc(5px * 2); }
 #vqkqrjxndc .gt_indent_3 { text-indent: calc(5px * 3); }
 #vqkqrjxndc .gt_indent_4 { text-indent: calc(5px * 4); }
 #vqkqrjxndc .gt_indent_5 { text-indent: calc(5px * 5); }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_row_group_first td { border-top-width: 2px; }
 #vqkqrjxndc .gt_row_group_first th { border-top-width: 2px; }
 #vqkqrjxndc .gt_striped { color: #333333; background-color: #F4F4F4; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #vqkqrjxndc .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #vqkqrjxndc .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #vqkqrjxndc .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #vqkqrjxndc .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #vqkqrjxndc .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #vqkqrjxndc .gt_left { text-align: left; }
 #vqkqrjxndc .gt_center { text-align: center; }
 #vqkqrjxndc .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #vqkqrjxndc .gt_font_normal { font-weight: normal; }
 #vqkqrjxndc .gt_font_bold { font-weight: bold; }
 #vqkqrjxndc .gt_font_italic { font-style: italic; }
 #vqkqrjxndc .gt_super { font-size: 65%; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #vqkqrjxndc .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; }
 #vqkqrjxndc .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #vqkqrjxndc .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #vqkqrjxndc .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">Table 6.4: E[S] by per-claim and aggregate limit</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="shifted" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">shifted gamma</th>
<th id="exact" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">exact, FFT</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">1M per claim, 1M aggregate</th>
<td class="gt_row gt_right" headers="stub-1 book">29,702</td>
<td class="gt_row gt_right" headers="stub-1 shifted">29,702</td>
<td class="gt_row gt_right" headers="stub-1 exact">30,133</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">1M per claim, 2M aggregate</th>
<td class="gt_row gt_right" headers="stub-2 book">30,306</td>
<td class="gt_row gt_right" headers="stub-2 shifted">30,306</td>
<td class="gt_row gt_right" headers="stub-2 exact">30,334</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">1M per claim, 3M aggregate</th>
<td class="gt_row gt_right" headers="stub-3 book">30,333</td>
<td class="gt_row gt_right" headers="stub-3 shifted">30,333</td>
<td class="gt_row gt_right" headers="stub-3 exact">30,335</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">1M per claim, 5M aggregate</th>
<td class="gt_row gt_right" headers="stub-4 book">30,335</td>
<td class="gt_row gt_right" headers="stub-4 shifted">30,335</td>
<td class="gt_row gt_right" headers="stub-4 exact">30,335</td>
</tr>
<tr>
<th id="stub-5" class="gt_row gt_left gt_stub" scope="row">2M per claim, 2M aggregate</th>
<td class="gt_row gt_right" headers="stub-5 book">33,524</td>
<td class="gt_row gt_right" headers="stub-5 shifted">33,523</td>
<td class="gt_row gt_right" headers="stub-5 exact">33,910</td>
</tr>
<tr>
<th id="stub-6" class="gt_row gt_left gt_stub" scope="row">2M per claim, 3M aggregate</th>
<td class="gt_row gt_right" headers="stub-6 book">33,915</td>
<td class="gt_row gt_right" headers="stub-6 shifted">33,915</td>
<td class="gt_row gt_right" headers="stub-6 exact">33,999</td>
</tr>
<tr>
<th id="stub-7" class="gt_row gt_left gt_stub" scope="row">2M per claim, 5M aggregate</th>
<td class="gt_row gt_right" headers="stub-7 book">34,002</td>
<td class="gt_row gt_right" headers="stub-7 shifted">34,002</td>
<td class="gt_row gt_right" headers="stub-7 exact">34,006</td>
</tr>
<tr>
<th id="stub-8" class="gt_row gt_left gt_stub" scope="row">3M per claim, 3M aggregate</th>
<td class="gt_row gt_right" headers="stub-8 book">35,421</td>
<td class="gt_row gt_right" headers="stub-8 shifted">35,420</td>
<td class="gt_row gt_right" headers="stub-8 exact">35,762</td>
</tr>
<tr>
<th id="stub-9" class="gt_row gt_left gt_stub" scope="row">3M per claim, 5M aggregate</th>
<td class="gt_row gt_right" headers="stub-9 book">35,781</td>
<td class="gt_row gt_right" headers="stub-9 shifted">35,780</td>
<td class="gt_row gt_right" headers="stub-9 exact">35,819</td>
</tr>
<tr>
<th id="stub-10" class="gt_row gt_left gt_stub" scope="row">5M per claim, 5M aggregate</th>
<td class="gt_row gt_right" headers="stub-10 book">37,428</td>
<td class="gt_row gt_right" headers="stub-10 shifted">37,427</td>
<td class="gt_row gt_right" headers="stub-10 exact">37,703</td>
</tr>
</tbody>
</table>


P6.11 asks for the share an aggregate limit equal to the per-claim limit removes:


``` python
compare([(f"P6.11, {l / 1e6:.0f}M per claim and aggregate", b,
          1 - exact_at[l, l] / exact_at[l, math.inf])
         for l, b in [(1e6, 0.0209), (2e6, 0.0142), (3e6, 0.0112), (5e6, 0.0081)]],
        "P6.11: share of the loss an aggregate limit removes")
```


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

#fshpsuquke thead, tbody, tfoot, tr, td, th { border-style: none; }
 tr { background-color: transparent; }
#fshpsuquke p { margin: 0; padding: 0; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_caption { padding-top: 4px; padding-bottom: 4px; }
 #fshpsuquke .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; }
 #fshpsuquke .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; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #fshpsuquke .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; }
 #fshpsuquke .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; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_column_spanner_outer:first-child { padding-left: 0; }
 #fshpsuquke .gt_column_spanner_outer:last-child { padding-right: 0; }
 #fshpsuquke .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%; }
 #fshpsuquke .gt_spanner_row { border-bottom-style: hidden; }
 #fshpsuquke .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; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_from_md> :first-child { margin-top: 0; }
 #fshpsuquke .gt_from_md> :last-child { margin-bottom: 0; }
 #fshpsuquke .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; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_indent_1 { text-indent: 5px; }
 #fshpsuquke .gt_indent_2 { text-indent: calc(5px * 2); }
 #fshpsuquke .gt_indent_3 { text-indent: calc(5px * 3); }
 #fshpsuquke .gt_indent_4 { text-indent: calc(5px * 4); }
 #fshpsuquke .gt_indent_5 { text-indent: calc(5px * 5); }
 #fshpsuquke .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; }
 #fshpsuquke .gt_row_group_first td { border-top-width: 2px; }
 #fshpsuquke .gt_row_group_first th { border-top-width: 2px; }
 #fshpsuquke .gt_striped { color: #333333; background-color: #F4F4F4; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #fshpsuquke .gt_first_summary_row { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; }
 #fshpsuquke .gt_last_summary_row_top { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }
 #fshpsuquke .gt_grand_summary_row { color: #333333; background-color: #FFFFFF; text-transform: inherit; padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; }
 #fshpsuquke .gt_first_grand_summary_row_bottom { border-top-style: double; border-top-width: 6px; border-top-color: #D3D3D3; }
 #fshpsuquke .gt_last_grand_summary_row_top { border-bottom-style: double; border-bottom-width: 6px; border-bottom-color: #D3D3D3; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #fshpsuquke .gt_left { text-align: left; }
 #fshpsuquke .gt_center { text-align: center; }
 #fshpsuquke .gt_right { text-align: right; font-variant-numeric: tabular-nums; }
 #fshpsuquke .gt_font_normal { font-weight: normal; }
 #fshpsuquke .gt_font_bold { font-weight: bold; }
 #fshpsuquke .gt_font_italic { font-style: italic; }
 #fshpsuquke .gt_super { font-size: 65%; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_footnote { margin: 0px; font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; }
 #fshpsuquke .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; }
 #fshpsuquke .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }
 #fshpsuquke .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }
 #fshpsuquke .gt_asterisk { font-size: 100%; vertical-align: 0; }
 
</style>

<table class="gt_table" aria-labelledby="title" 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">P6.11: share of the loss an aggregate limit removes</th>
</tr>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" scope="col"></th>
<th id="book" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">book</th>
<th id="prospicio" class="gt_col_heading gt_columns_bottom_border gt_right" scope="col">prospicio</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr>
<th id="stub-1" class="gt_row gt_left gt_stub" scope="row">P6.11, 1M per claim and aggregate</th>
<td class="gt_row gt_right" headers="stub-1 book">0.0209</td>
<td class="gt_row gt_right" headers="stub-1 prospicio">0.0066</td>
</tr>
<tr>
<th id="stub-2" class="gt_row gt_left gt_stub" scope="row">P6.11, 2M per claim and aggregate</th>
<td class="gt_row gt_right" headers="stub-2 book">0.0142</td>
<td class="gt_row gt_right" headers="stub-2 prospicio">0.0028</td>
</tr>
<tr>
<th id="stub-3" class="gt_row gt_left gt_stub" scope="row">P6.11, 3M per claim and aggregate</th>
<td class="gt_row gt_right" headers="stub-3 book">0.0112</td>
<td class="gt_row gt_right" headers="stub-3 prospicio">0.0016</td>
</tr>
<tr>
<th id="stub-4" class="gt_row gt_left gt_stub" scope="row">P6.11, 5M per claim and aggregate</th>
<td class="gt_row gt_right" headers="stub-4 book">0.0081</td>
<td class="gt_row gt_right" headers="stub-4 prospicio">0.0008</td>
</tr>
</tbody>
</table>


P6.12 prices a 1M per-claim limit with v = 25%:


``` python
print(f"P6.12  premium, 1M per claim, v = 25%: book 40,447, prospicio "
      f"{exact_at[1e6, math.inf] / 0.75:,.0f}")
print(f"P6.12  credit for a 1M aggregate limit: book 844, "
      f"exact {(exact_at[1e6, math.inf] - exact_at[1e6, 1e6]) / 0.75:,.0f}")
```


    P6.12  premium, 1M per claim, v = 25%: book 40,447, prospicio 40,446
    P6.12  credit for a 1M aggregate limit: book 844, exact 269


The shifted gamma column matches the monograph to a unit or so (it integrated numerically), which confirms the method and μ = 7.6. Where the aggregate limit equals the per-claim limit, the approximation removes three to ten times the loss that is there, and P6.12's credit for a 1M aggregate limit falls from 844 to about a third of that. P6.12's unlimited premium needs no approximation. It agrees up to the monograph's rounding of 30,335 before it divides, the same rounding that gives its basic loss of 26,092 and standard deviation of 151,311.


# 10. What agreed and what did not

These values agree to the printed digits:

- Ex 3.1 to 3.5, 3.8, 3.9, P3.3, P3.4, P3.11 to P3.13, P3.15 and P3.28 to P3.31.
- Ex 4.1, 4.2 (moments and Table 4.1), 4.3, 4.4, 4.5, 4.8, P4.1 and P4.16, and the exact, normal and shifted gamma columns of Tables 4.3 and 4.4 and P4.13.
- Ex 6.6's moments and its 91, Table 6.4's shifted gamma values and P6.12's premium, up to the monograph's rounding of intermediate values (a unit or so).

These values did not agree:

- **Ex 3.3's chi-square**, 2.45 against 2.43: rounded expected counts.
- **Ex 3.6's α**, 2.44302 against 2.44285: a rounded sample variance. Its chi-square of 0.7753 is not reproduced (near 0.65 here).
- **Ex 6.6's μ**: printed 7.000, used 7.6.
- **Table 6.4, P6.11 and P6.12's credit** are right for the monograph's shifted gamma, several times too large for the actual aggregate.

Where to go next:

- [Severity and frequency](severity-and-frequency.md): count families by dispersion.
- [Aggregate distributions](aggregate-distributions.md): when FFT, Panjer, simulation or moments are exact, fast or unsafe.
- [Experience and exposure rating](experience-and-exposure-rating.md): excess counts and layers.
- [Claim size, layers, limits and deductibles](distributions-for-actuaries-claim-size.md): chapters 2, 5 and 6.
