Skip to main content

Counting

Trait Counting 

Source
pub trait Counting {
    // Required methods
    fn pmf(&self, k: u64) -> f64;
    fn mean(&self) -> f64;
    fn variance(&self) -> f64;
    fn panjer_ab(&self) -> (f64, f64);
    fn pgf(&self, z: f64) -> f64;
    fn pgf_complex(&self, z: (f64, f64)) -> (f64, f64);

    // Provided methods
    fn cdf(&self, k: u64) -> f64 { ... }
    fn quantile(&self, p: f64) -> Result<u64> { ... }
    fn sample(&self, rng: &mut StreamRng, n: usize) -> Vec<u64> { ... }
}
Expand description

A distribution of claim counts in the (a, b, 0) class.

Required Methods§

Source

fn pmf(&self, k: u64) -> f64

P(N = k).

Source

fn mean(&self) -> f64

E[N].

Source

fn variance(&self) -> f64

Var[N].

Source

fn panjer_ab(&self) -> (f64, f64)

(a, b) with p_k = (a + b / k) p_{k-1} for k ≥ 1.

Source

fn pgf(&self, z: f64) -> f64

Probability generating function E[z^N] for 0 ≤ z ≤ 1. Panjer’s recursion starts from P(S = 0) = pgf(f_0).

Source

fn pgf_complex(&self, z: (f64, f64)) -> (f64, f64)

The pgf at a complex z = (re, im) with |z| ≤ 1, as (re, im). FFT aggregation applies it to the transform of the severity grid.

Provided Methods§

Source

fn cdf(&self, k: u64) -> f64

P(N ≤ k).

Source

fn quantile(&self, p: f64) -> Result<u64>

Smallest k with P(N ≤ k) ≥ p. p = 1 gives u64::MAX.

Source

fn sample(&self, rng: &mut StreamRng, n: usize) -> Vec<u64>

n counts from stream rng, by inverse transform.

Each draw walks the pmf from 0, so the cost grows with the mean; fine for the claim counts of a year, slow for means in the hundreds of thousands.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Counting + ?Sized> Counting for Box<T>

Source§

fn pmf(&self, k: u64) -> f64

Source§

fn mean(&self) -> f64

Source§

fn variance(&self) -> f64

Source§

fn panjer_ab(&self) -> (f64, f64)

Source§

fn pgf(&self, z: f64) -> f64

Source§

fn pgf_complex(&self, z: (f64, f64)) -> (f64, f64)

Source§

fn cdf(&self, k: u64) -> f64

Source§

fn quantile(&self, p: f64) -> Result<u64>

Source§

fn sample(&self, rng: &mut StreamRng, n: usize) -> Vec<u64>

Implementors§