#distribution #risk #characteristics #utilities

cf_dist_utils

A library which has risk and distribution utilities

20 releases

0.10.0 Sep 1, 2021
0.9.1 Nov 27, 2020
0.9.0 Mar 2, 2019
0.7.2 Dec 19, 2018
0.2.0 Jul 16, 2018

#1605 in Algorithms

Download history 2/week @ 2024-02-16 12/week @ 2024-02-23 2/week @ 2024-03-01 153/week @ 2024-03-15 27/week @ 2024-03-22 20/week @ 2024-03-29 7/week @ 2024-04-05

168 downloads per month
Used in 2 crates

MIT license

19KB
294 lines

[lin-badge]: https://github.com/danielhstahl/cf_dist_utils_rust/workflows/Rust/badge.svg [cov-badge]: https://codecov.io/gh/danielhstahl/cf_dist_utils_rust/branch/master/graph/badge.svg

Linux Codecov
![lin-badge] ![cov-badge]

cf_dist_utils

This is a set of utilities to wrap around my fang_oost library. Documentation is on docs.rs. The main features are the ability to compute VaR, the CDF of a distribution, and the expected shortfall of a distribution.

using cf_dist_utils

Put the following in your Cargo.toml:

[dependencies]
cf_dist_utils = "0.10"

Import and use:

extern crate num_complex;
use num_complex::Complex;
extern crate cf_dist_utils;
let mu=2.0;
let sigma=5.0;
let num_u=128;
let x_min=-20.0;
let x_max=25.0;
let max_iterations=1000;
let tolerance=0.0000001;
let alpha=0.05;
let norm_cf=|u:&Complex<f64>| (u*mu+0.5*sigma*sigma*u*u).exp();
let (estimated_es, estimated_var)=cf_dist_utils::get_expected_shortfall_and_value_at_risk(
    alpha, num_u, x_min, x_max, max_iterations, tolerance, norm_cf
);

Benchmarks

https://danielhstahl.github.io/cf_dist_utils_rust/report/index.html

Dependencies

~2.1–3MB
~61K SLoC