jetblack-options 0.1.1

Functions for calculating option values and sensitivities, both analytically and using and finite difference methods.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use core::f64;

use libm::erf;

/// Cumulative distribution function.  P(X <= x)
pub fn cdf(x: f64, mu: f64, sigma: f64) -> f64 {
    if sigma < 0.0 {
        return f64::NAN; // sigma must be non-negative
    }

    if sigma == 0.0 {
        return f64::NAN; // Err("cdf() not defined when sigma is zero");
    }

    0.5 * (1.0 + erf((x - mu) / (sigma * f64::consts::SQRT_2)))
}