Skip to content

Releases: quants-net/MathPF

v0.5.0

26 May 05:26

Choose a tag to compare

What's new

New module: mathpf.mills_dd — symmetric divided differences of the Mills ratio for the Black-Scholes price-to-vega ratio.

New public API

mathpf.millsratio_dd(x, dx, theta=1)
#   theta = +1: (R(x-dx) - R(x+dx)) / (2 dx)   = Cv/sigma  (call branch)
#   theta = -1: (R(dx-x) + R(x+dx)) / (2 dx)   = (1-Cv)/sigma  (above branch)

mathpf.millsratio_dd_asymp(x, dx, n_terms=4)
#   Deep-OTM cancellation-free DD via the analytic 1/(z^2+3) asymptotic.
#   n_terms in {2,3,4,5} reaches ~100*eps at x - dx >= 352, 99.6, 51.2, 32.7.

The theta=+1 dispatcher splits into three regimes — asymp / R'''-seeded Taylor / direct mc.R difference — to keep relative error near eps across the full (x, dx) plane.

cdef kernels are noexcept nogil and re-use the existing mathpf.mills kernels via Cython cimport.

Notes

  • theta=-1 is not a literal divided difference — it's the BS above-inflection representation (1-Cv)/sigma, evaluated at two positive arguments to avoid cancellation for x < 0. See module docstring.

Full Changelog: v0.4.1...v0.5.0

v0.4.1

26 May 00:13
2125f83

Choose a tag to compare

What's changed

millsratio_d1 (−R′) and millsratio_d3 (−R‴) now accept any x (previously raised for x<0), via the reflection from R(x)+R(−x)=√(2π)·e^{x²/2}:

  • R1(x) = √(2π)·(−x)·e^{x²/2} + R1(−x)
  • R3(x) = √(2π)·(−x)·(x²+3)·e^{x²/2} + R3(−x)

millsratio_rel_below1 remains strict to [0,1]. Accuracy ≤1.4 eps vs mpmath down to x=−20 (conditioning-limited by e^{x²/2}); positive-x behavior unchanged.

See #2.

v0.4.0

25 May 22:26
af7817d

Choose a tag to compare

What's new

New compiled module mathpf.mills — the Mills ratio R(x)=N(-x)/n(x) and its derivatives:

  • millsratio (R), millsratio_d1 (−R′), millsratio_d3 (−R‴), millsratio_rel_below1 ((√(π/2)−R)/x on [0,1])
  • Cimport-able C kernels _R / _R1 / _R3 / _Rrel_below1 (noexcept nogil) for downstream Cython use
  • Segmented Chebyshev (flat bucket-major tables) + tiered Laplace continued fraction; data in _mills_coef.h (static const double[], C/C++-includable)
  • Bit-identical to the mpmath-verified reference; ~190× faster than the scalar Python loop

See #1.