Every program in the book

The DecL declarations behind the recitations, collected

Author

Stephen J. Mildenhall

Published

2026-10-22 19:58 commit b7145b5+

This appendix collects every DecL program the book builds, chapter by chapter, in the order the chapters appear, each chapter’s programs headed by the text they come from and a link back to the chapter. It is not transcribed. Each chapter writes the programs it parses into a store as it runs, and this page reads the store back, so the appendix cannot drift from the chapters the way a hand-maintained list would. What is printed is the canonical form: the declaration re-parsed and written back from the resulting specification, which is what the library understood rather than what was typed.

Three things follow from generating it this way. A chapter that builds nothing does not appear, and neither does a portfolio assembled in Python from aggregates already built, since no declaration was parsed to make it. Programs are collected by declaration rather than by object, so a chapter that rebuilds one model at several bucket sizes contributes one entry and not several, and where it swept the grid the hints{} clause is dropped, since no one setting is the model’s. And the numerical arguments some chapters pass to build as keyword arguments are not here at all: those are instructions to the solver, not part of the declaration, and the chapters that depend on them say so where they use them.

Declarations that share a shape are sampled when there are more than three of them, where a shape is the declaration with its numbers taken out. Two are shown, followed by a count of the rest. A group life example that writes one Bernoulli aggregate per employee contributes two of its fourteen, and nothing is hidden by this that is not an arithmetic variant of something on the page beside it. A shape with three or fewer members is printed in full, because in a book of exercises two declarations of one shape are usually two different problems.

Every program below runs as it stands, in the aggregate Loss Lab with no installation, or through build in a Python session.

The same declarations are also available as one loadable file, recitations.agg in the project root, written from the same store by make_agg.py. Each one there carries a note{} naming the text it comes from and the example or exercise it works, and each is renamed by citation key so that nothing in the file shadows anything else: build.load('recitations.agg') puts all of them in the recipe base, after which build('Klugman2019.KPW.9.19') rebuilds that exercise by name. A model that more than one chapter builds appears there once.

Klugman, Panjer and Willmot on aggregate loss models

From Klugman et al. (2019), worked in Klugman, Panjer and Willmot on aggregate loss models.

agg KPW.95
  dfreq [0 1 2 3 4 5 6 7 8] [0.05 0.1 0.15 0.2 0.25 0.15 0.06 0.03 0.01]
  dsev [1 2 3 4 5 6 7 8 9 10] [0.15 0.2 0.25 0.125 0.075 0.05 0.05 0.05 0.025 0.025]
agg KPW.9.19
  dfreq [0 1 3] [0.5 0.4 0.1]
  dsev [1 10] [0.9 0.1]
agg KPW.9.23
  dfreq [0 1 2 3] [0.5 0.2 0.2 0.1]
  sev 3 * norm + 100
agg KPW.9.24
  dfreq [0 1 2 3 4] [0.0625 0.25 0.375 0.25 0.0625]
  dsev [2 3] [0.4 0.6]
  aggregate net of
    inf xs 5
agg KPW.9.31
  [2 3] claims
  sev [1000 200] * uniform
  occurrence ceded to
    inf xs 100
  poisson
agg KPW.9.34
  5 claims
  dsev [1 5 10] [0.8 0.16 0.04]
  poisson
agg KPW.9.9
  3 claims
  dsev [1 2 3] [0.6333333333333333 0.26666666666666666 0.09999999999999999]
  poisson
agg KPW.9.35
  96 claims
  sev 8 * uniform
  mixed gamma 0.25
agg KPW.9.36
  3 claims
  sev 2 * burr12 1 3
  poisson
port KPW.9.9.p
  agg A
    2 claims
    dsev [1 2] [0.6 0.4]
    poisson
  agg B
    1 claim
    dsev [1 3] [0.7 0.3]
    poisson
agg KPW.9.39
  1.2 claims
  sev expon
  binomial 0.4
port kpw_9_40
  agg A
    50 claims
    dsev [10]
    poisson
  agg B
    60 claims
    dsev [20]
    poisson
  agg C
    30 claims
    dsev [40]
    poisson
agg KPW.9.11
  0.9 claims
  dsev [0 50 150] [0.3 0.5 0.2]
  binomial 0.3 zm 0.4
agg KPW.9.45
  6 claims
  dsev [1 2 4]
  poisson
agg KPW.9.47
  2 claims
  dsev [1 2] [0.25 0.75]
  poisson
agg KPW.9.57
  3 claims
  dsev [1 2 3 4] [0.4 0.3 0.2 0.1]
  poisson
agg KPW.9.58
  3 claims
  dsev [1 2 3 4] [0.4 0.3 0.2 0.1]
  mixed gamma 0.408248290463863
agg KPW.9.59
  5 claims
  sev 2500 * gamma 0.5
  poisson
agg KPW.9.60
  40 claims
  dsev [5 10] [0.75 0.25]
  neyman 4
agg KPW.9.14
  3 claims
  18 xs 6
  sev 10 * pareto 4 + -10 !
  occurrence net of
    25% po inf xs 0
  poisson
agg KPW.9.63
  1.4 claims
  125 xs 50
  sev 100 * gamma 2 !
  mixed gamma 0.7071067811865476
port KPW.9.15.p
  agg A
    0.5 claims
    dsev [50 100] [0.7 0.3]
    binomial 0.01
  agg B
    0.25 claims
    dsev [75 150] [0.7 0.3]
    binomial 0.01
agg KPW.9.15.w
  0.75 claims
  dsev [50 75 100 150] [0.4666666666666666 0.2333333333333333 0.19999999999999998 0.09999999999999999]
  binomial 0.01
agg KPW.9.15.cp
  0.75 claims
  dsev [50 75 100 150] [0.4666666666666666 0.2333333333333333 0.19999999999999998 0.09999999999999999]
  poisson
agg ee.1
  0.00149 claims
  dsev [15]
  bernoulli
agg ee.2
  0.00142 claims
  dsev [16]
  bernoulli

and 12 more of this shape, differing only in their numbers.

agg kpw_9_16.po
  0.048130000000000006 claims
  dsev [14 15 16 17 18 19 20 24 26 28 30 31 55 60] [0.01038853 0.03095782 0.02950343 0.01038853 0.07334303 0.01121961 0.02659464 0.10056098 0.08186162 0.02534802 0.02140037 0.02555579 0.09952213 0.4533555]
  poisson
agg Class.1
  50 claims
  dsev [1]
  binomial 0.1
agg Class.2
  10 claims
  dsev [2]
  binomial 0.02

and 3 more of this shape, differing only in their numbers.

agg Class.2.c
  10 claims
  dsev [1]
  binomial 0.02
agg Class.3.c
  10 claims
  dsev [2]
  binomial 0.02

and 2 more of this shape, differing only in their numbers.

agg CP.Approx
  100 claims
  dsev [1 2] [0.9 0.1]
  poisson
port KPW.9.74p
  agg A
    10 claims
    sev 500 * expon
    binomial 0.02
  agg B
    7.5 claims
    sev 750 * expon
    binomial 0.03
  agg C
    10 claims
    sev 1000 * expon
    binomial 0.04
agg KPW.9.74.cp
  [10 7.5 10] claims
  sev [500 750 1000] * expon
  poisson

Frees on severity, coverage modifications and aggregate losses

From Frees (2018), worked in Frees on severity, coverage modifications and aggregate losses.

agg lda.3.3.5
  1 claim
  sev [200 200] * [expon pareto] [1 3] + [0 -200] wts [0.25 0.75]
  fixed
agg lda.3.4.1
  1 claim
  inf xs 100
  sev 1000 * expon 1 !
  fixed
agg lda.3.4.2
  1 claim
  6 xs 4
  sev 10 * beta 2 1
  fixed
agg X06
  1 claim
  500 xs 100
  sev 1000 * expon
  fixed
agg X07
  1 claim
  500 xs 100
  sev 1050 * expon
  fixed
agg insurer.net
  1 claim
  5000 xs 0
  sev 3600 * pareto 5 + -3600
  occurrence net of
    15% po 5000 xs 0
  fixed
agg QU
  12 claims
  dsev [1 2 3] [0.5 0.3333333333333333 0.16666666666666666]
  poisson
agg lda.5.3.2
  dfreq [1 2] [0.8 0.2]
  dsev [0 100 1000] [0.2 0.7 0.1]
agg lda.5.3.3
  4 claims
  dsev [1 2 3 4]
  geometric
agg Pharma
  25 claims
  sev 90 * uniform + 5
  poisson
agg Projects
  2 claims
  dsev [5 10 20] [0.2 0.3 0.5]
  geometric
  aggregate net of
    15 xs 0
agg Projects.1
  2 claims
  dsev [5 10 20] [0.2 0.3 0.5]
  geometric
  aggregate ceded to
    inf xs 0
agg Projects.1
  2 claims
  dsev [5 10 20] [0.2 0.3 0.5]
  geometric
  aggregate ceded to
    inf xs 5

and 2 more of this shape, differing only in their numbers.

agg LDA554
  3 claims
  sev 50 * burr12 1 3
  poisson zm 0.5
agg Original
  300 claims
  dsev [4 8 12 20]
  mixed gamma 0.07453559924999298
agg Revised
  300 claims
  inf xs 10
  sev dhistogram xps [6 12 18 30] [0.25 0.25 0.25 0.25] !
  mixed gamma 0.07453559924999298
agg Auto
  16 claims
  inf xs 100
  sev 200 * expon !
  poisson
agg Auto
  16 claims
  inf xs 100
  sev 200 * expon
  poisson
agg VaR
  1 claim
  dsev [1 3 4] [0.75 0.2 0.05]
  fixed
port retained
  agg building
    1 claim
    100 xs 0
    sev 100 * gamma 2
    fixed
  agg motor
    1 claim
    200 xs 0
    sev 200 * gamma 2
    fixed
port insured
  agg building
    1 claim
    inf xs 100
    sev 100 * gamma 2 !
    fixed
  agg motor
    1 claim
    inf xs 200
    sev 200 * gamma 2 !
    fixed
  agg d.and.o
    1 claim
    sev 1000 * pareto 2
    fixed
  agg cyber
    1 claim
    sev 2000 * pareto 3
    fixed
port total
  agg building
    1 claim
    sev 100 * gamma 2
    fixed
  agg motor
    1 claim
    sev 200 * gamma 2
    fixed
  agg d.and.o
    1 claim
    sev 1000 * pareto 2
    fixed
  agg cyber
    1 claim
    sev 2000 * pareto 3
    fixed

Bahnemann on aggregate distributions and layer pricing

From Bahnemann (2015), worked in Bahnemann on aggregate distributions and layer pricing.

agg Bahn.4.1
  dfreq [0 1 2] [0.6 0.3 0.1]
  dsev [1 2 3] [0.4 0.5 0.1]
agg Bahn.4.2
  2.5 claims
  sev 400 * gamma 3
  poisson
agg Bahn.4.5
  2.5 claims
  sev 400 * gamma 3
  poisson
agg Bahn.4.7
  8 claims
  sev 3750 * gamma 0.2
  poisson
agg Bahn.4.2b
  10 claims
  sev 6000 * gamma 0.05
  poisson
agg Bahn.4.4
  1.75 claims
  dsev [1 2 3 4 5] [0.2 0.4 0.2 0.15 0.05]
  poisson
agg Bahn.4.15
  3 claims
  1000 xs 0
  sev 403.4287934927351 * lognorm 1.5
  poisson
agg Bahn.5.13
  15 claims
  5000 xs 3000
  sev 395.7964246880697 * lognorm 1.8 !
  poisson
agg Bahn.5.13b
  1.9535923221305609 claims
  5000 xs 3000
  sev 395.7964246880697 * lognorm 1.8
  poisson
agg Bahn.6.3
  1 claim
  sev 1096.6331584284585 * lognorm 2.4
  fixed
agg Bahn.6.5
  0.2 claims
  [100000 500000 1000000 2000000 3000000 4000000 5000000] xs 0
  sev 1096.6331584284585 * lognorm 2.4
  poisson
agg Bahn.6.6
  1.2 claims
  500000 xs 0
  sev 1998.1958951041172 * lognorm 2.4
  mixed gamma 0.31622776601683794
  aggregate ceded to
    1000000 xs 0 and
    1000000 xs 1000000 and
    1000000 xs 2000000 and
    1000000 xs 3000000 and
    1000000 xs 4000000 and
    inf xs 5000000
agg Bahn.6.6
  1.2 claims
  1000000 xs 0
  sev 1998.1958951041172 * lognorm 2.4
  mixed gamma 0.31622776601683794
  aggregate ceded to
    1000000 xs 0 and
    1000000 xs 1000000 and
    1000000 xs 2000000 and
    1000000 xs 3000000 and
    1000000 xs 4000000 and
    inf xs 5000000
agg Bahn.6.6
  1.2 claims
  2000000 xs 0
  sev 1998.1958951041172 * lognorm 2.4
  mixed gamma 0.31622776601683794
  aggregate ceded to
    2000000 xs 0 and
    1000000 xs 2000000 and
    1000000 xs 3000000 and
    1000000 xs 4000000 and
    inf xs 5000000
agg Bahn.6.6
  1.2 claims
  3000000 xs 0
  sev 1998.1958951041172 * lognorm 2.4
  mixed gamma 0.31622776601683794
  aggregate ceded to
    3000000 xs 0 and
    1000000 xs 3000000 and
    1000000 xs 4000000 and
    inf xs 5000000
agg Bahn.6.6
  1.2 claims
  4000000 xs 0
  sev 1998.1958951041172 * lognorm 2.4
  mixed gamma 0.31622776601683794
  aggregate ceded to
    4000000 xs 0 and
    1000000 xs 4000000 and
    inf xs 5000000
agg Bahn.6.6
  1.2 claims
  5000000 xs 0
  sev 1998.1958951041172 * lognorm 2.4
  mixed gamma 0.31622776601683794
  aggregate ceded to
    5000000 xs 0 and
    inf xs 5000000
agg Bahn.6.7
  0.0005 claims
  [100000 99000 98000 97000 96000 95000 90000] xs [0 1000 2000 3000 4000 5000 10000]
  sev 1096.6331584284585 * lognorm 2.4 !
  poisson

Brehm et al. on reinsurance in enterprise risk analysis

From Brehm et al. (2007), worked in Brehm et al. on reinsurance in enterprise risk analysis.

port ABCD
  agg Casualty
    14 premium at 0.78 lr
    5 xs 0
    sev lognorm 0.1 cv 10
    mixed gamma 0.3
  agg PropertyNC
    17 premium at 0.63 lr
    25 xs 0
    sev lognorm [0.1 1] cv [5 10] wts [0.7 0.3]
    mixed gamma 0.1
  agg PropertyC
    2 premium at 0.63 lr
    150 xs 0
    sev 3 * pareto 2.375 + -3
    poisson
port ABCD:Net
  agg Casualty
    14 premium at 0.78 lr
    5 xs 0
    sev lognorm 0.1 cv 10
    occurrence net of
      4 xs 1
    mixed gamma 0.3
  agg PropertyNC
    17 premium at 0.63 lr
    25 xs 0
    sev lognorm [0.1 1] cv [5 10] wts [0.7 0.3]
    occurrence net of
      17 xs 3
    mixed gamma 0.1
  agg PropertyC
    2 premium at 0.63 lr
    150 xs 0
    sev 3 * pareto 2.375 + -3
    occurrence net of
      24 xs 1
    poisson
port ABCD:Ceded
  agg Casualty
    14 premium at 0.78 lr
    5 xs 0
    sev lognorm 0.1 cv 10
    occurrence ceded to
      4 xs 1
    mixed gamma 0.3
  agg PropertyNC
    17 premium at 0.63 lr
    25 xs 0
    sev lognorm [0.1 1] cv [5 10] wts [0.7 0.3]
    occurrence ceded to
      17 xs 3
    mixed gamma 0.1
  agg PropertyC
    2 premium at 0.63 lr
    150 xs 0
    sev 3 * pareto 2.375 + -3
    occurrence ceded to
      24 xs 1
    poisson

Casualty Actuarial Society examination questions

From the examinations cited in Casualty Actuarial Society examination questions.

port CASq15
  agg X1
    1 claim
    dsev [0 5] [0.85 0.15]
    fixed
  agg X2
    1 claim
    dsev [0 15] [0.99 0.01]
    fixed

5 chapters build 97 distinct programs between them, of which 78 are printed above and 19 are further declarations of a shape already shown.

Bahnemann, D. (2015). Distributions for Actuaries. Casualty Actuarial Society Monographs No. 2. www.casact.org
Brehm, P. J., Perry, J. H., Venter, G. G., & Witcraft, S. E. (2007). Enterprise Risk Analysis. Casualty Actuarial Society.
Frees, E. (2018). Loss Data Analytics. Open Actuarial Texts. https://openacttexts.github.io/Loss-Data-Analytics/
Klugman, S. A., Panjer, H. H., & Willmot, G. E. (2019). Loss Models: from data to decisions (Fifth.). John Wiley & Sons.