aggregate.Ledger
Usage
aggregate.Ledger()values and their probabilities) and its groups, with every row (each leg, each side’s total, each group’s result, running nets, tier and net-of blocks, and with several groups the grand rows and the total impact) a sum of signed legs at each atom, and its exact distribution.
The scenario columns k01 to k99 (aggregate’s κ) are each row’s conditional mean given that the grand result equals its quantile at that level, so each column is one state of the world and foots down the sheet. Rows are in the payoff convention: k01 is the bad year. The source’s probabilities are rescaled to sum to 1.
Parameters
source: Grid or tuple of (list of float, list of float)groups: list of Groupname: str = "ledger"result_name: str = "result"spans: list of tuple of (str, int, int)-
(label, lo, hi): groupslotohi - 1with their own subtotal block, and a net-of block when a later group follows. force_tower: bool = False- Present one group as a tower, with a step level.
Examples
>>> from prospicio.aggregate import Group, Ledger, Leg
>>> book = Group("Book", "sell", [Leg("Premium", 10.0)], [Leg("Loss", lambda x: x)])
>>> pnl = Ledger(([2.0, 8.0], [0.5, 0.5]), [book], name="Book")
>>> pnl.result.mean()5.0
>>> s = pnl.sheet()
>>> s["label"], s["k01"]([‘Premium’, ‘Loss’, ‘Total’], [10.0, -8.0, 2.0])
Attributes
| Name | Description |
|---|---|
| is_stitched | Whether every row is its own marginal (Book.occurrence_peel()): |
| name | The ledger’s name. |
| prob_eq_0 | The chance that the result is 0. |
| result | The (grand) result’s distribution. |
| rows | The rows’ labels, in sheet order. |
is_stitched
Whether every row is its own marginal (Book.occurrence_peel()):
is_stitched: bool
the sheet then has no scenario columns.
name
The ledger’s name.
name: str
prob_eq_0
The chance that the result is 0.
prob_eq_0: float
result
The (grand) result’s distribution.
result: Discrete
rows
The rows’ labels, in sheet order.
rows: list[str]
Methods
| Name | Description |
|---|---|
| card() |
The card, aggregate’s summary_df: each block’s consideration,
|
| legs() |
The declared legs, aggregate’s legs_df: step, side, label,
|
| marginal() |
Each row’s own quantiles, aggregate’s economic_marginal_df:
|
| ratios() |
The ratio exhibit, aggregate’s economic_ratios_df: for each
|
| row() | The distribution of the row labelled label. |
| sheet() |
The sheet, aggregate’s economic_df: every row with its mean,
|
| validation() | Each rebucketed leg’s exact mean against its grid’s, |
card()
The card, aggregate’s summary_df: each block’s consideration,
Usage
card()obligation and margin (and on a tower each step’s running net and the covers’ total impact), with EX, SD, CV, Skew, P01, Median and P99 of each row’s own distribution.
Returns
dict
legs()
The declared legs, aggregate’s legs_df: step, side, label,
Usage
legs()kind, EX and SD.
Returns
dict
marginal()
Each row’s own quantiles, aggregate’s economic_marginal_df:
Usage
marginal()P01 to P99, which do not add down the sheet.
Returns
dict
ratios()
The ratio exhibit, aggregate’s economic_ratios_df: for each
Usage
ratios()group, span, net-of block and All, premium P, loss L net of recoveries, expense E net of commission and the result M (mean amounts, signed for the block’s own view), the result’s SD, the ratios of means LR, ER, CR, the means of ratios E_LR, E_ER, E_CR (where the premium never vanishes), and P_share and M_share of the first block. Legs without a kind count as premium on the consideration side and loss on the other.
Returns
dict
row()
The distribution of the row labelled label.
Usage
row(label)Parameters
label: str
Returns
Discrete
Raises
ValueError-
No such row, or a stitched peel’s
Impactrow, a difference of statistics with no distribution of its own.
sheet()
The sheet, aggregate’s economic_df: every row with its mean,
Usage
sheet()standard deviation, coefficient of variation, skewness and scenario columns k01 to k99.
Returns
dict-
Columns step (on a tower),
side, label, row (the row’s key),EX,SD,CV,Skewand the scenarios (none on a stitched peel, Book.occurrence_peel()).
validation()
Each rebucketed leg’s exact mean against its grid’s,
Usage
validation()Returns
dict-
Columns label,
EX,Est,abs_errandrel_err.