merton.core.distance¶
Distance-to-default and probability-of-default primitives.
These are the most-called functions in the whole package. They accept any combination of scalar and array inputs (NumPy-style broadcasting) and dispatch to the fastest available backend.
Examples
>>> from merton import distance_to_default, prob_of_default
>>> dd = distance_to_default(100, 0.25, 60, 0.04, 1.0)
>>> float(round(dd, 4))
2.0783
>>> float(round(prob_of_default(dd), 6))
0.018841
Functions¶
|
Compute Merton's distance-to-default |
|
Risk-neutral probability of default given the distance-to-default. |
Module Contents¶
- merton.core.distance.distance_to_default(asset_value: merton._typing.ArrayLike, asset_vol: merton._typing.ArrayLike, debt: merton._typing.ArrayLike, rf: merton._typing.ArrayLike, T: merton._typing.ArrayLike, *, dividend_yield: merton._typing.ArrayLike = 0.0, backend: str | None = None, validate: bool = True) merton._typing.FloatArray[source]¶
Compute Merton’s distance-to-default
DD = d_2.\[DD = \frac{\ln(A/D) + (r - q - \sigma_A^2 / 2)\, T}{\sigma_A \sqrt{T}}\]- Parameters:
asset_value – Firm asset value(s)
A(strictly positive).asset_vol – Annualised asset volatility
σ_A(strictly positive).debt – Default threshold
D(strictly positive). For real firms this is typically computed viamerton.core.compute_default_point().rf – Risk-free rate
r(decimal).T – Horizon in years (strictly positive).
dividend_yield – Continuous dividend yield
q. Defaults to 0.backend – Force a particular backend.
validate – If True, check for non-finite and out-of-domain inputs.
- Returns:
DD— number of asset-volatility standard deviations between the log of assets and the log of the default threshold.- Return type:
FloatArray
References
Merton (1974). Vassalou & Xing (2004). Crosbie & Bohn (2003).
Examples
>>> import numpy as np >>> dd = distance_to_default( ... asset_value=np.array([100.0, 150.0]), ... asset_vol=0.25, ... debt=60.0, ... rf=0.04, ... T=1.0, ... ) >>> dd.shape (2,)
- merton.core.distance.prob_of_default(dd: merton._typing.ArrayLike, *, backend: str | None = None) merton._typing.FloatArray[source]¶
Risk-neutral probability of default given the distance-to-default.
\[\text{PD} = \Phi(-DD)\]where \(\Phi\) is the standard-normal CDF.
Examples
>>> import numpy as np >>> float(round(prob_of_default(2.5), 5)) 0.00621