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

Fang-Oosterlee Library for Rust

Implements Fang-Oosterlee algorithm in Rust. While the algorithm originally was used for option pricing, it can be used for a variety of use cases. For example, it can be used to compute the Value at Risk of a distribution, the density of a distribution, and the partial expectation.

It requires a characteristic function computed at various specific intervals. A utility function is provided which converts an analytical characteristic function into a vector.

Documentation is at docs.rs

Use

Put the following in your Cargo.toml:

toml [dependencies] fang_oost = "0.13"

Import and use:

```rust extern crate numcomplex; extern crate fangoost; extern crate rayon; use rayon::prelude::*; use num_complex::Complex;

let numx = 1024; let numu = 256; let xmin = -20.0; let xmax = 25.0; let mu=2.0; let sigma:f64=5.0; let normcf = |u:&Complex|(u*mu+0.5*u*u*sigma*sigma).exp(); let xdomain=fangoost::getxdomain(numx, xmin, xmax); //computes discrete gaussian characteristic function let discretecf=fangoost::getdiscretecf(numu, xmin, xmax, &normcf); let density:Vec = fangoost::getdensity( xmin, xmax, xdomain, &discretecf ).collect(); ```

Related Crates

Benchmarks

View benchmarks at https://phillyfan1138.github.io/fangoostrust/report/index.html.