model_clo_insight.analysis.stats module¶
Statistical Module for Monte Carlo Default / Loss Distributions
Computes the rating-based cumulative default/loss hurdles, and diagnostic statistics at both the pool and loan level.
- _solve_for_rho(a, b)¶
Solves for Vasicek correlation for a given mean and variance
Solves for rho within a Vasicek distribution such that the observed mean and variance are at the target
- _variance_func(x, y, z)¶
Used in correlation solver
- Returns
variance for a Vasicek distribution
- Return type
Notes
Uses Numpy multivariate normal distribution
- calc_default_diagnostics(def_pct_matrix)¶
Computes the expected (exposure at default) per loan based on the simulation results
- Parameters
def_pct_matrix (ndarray) – simulation results from model_clo_insight.engines.LGD.calc_def_pct_from_amort()
- Returns
exposure at default per loan
- Return type
ndarray
- calc_rating_percentile(target_pd, loss_dist)¶
Computes Rating-Based Cumulative Default / Loss Thresholds
- Parameters
target_pd (float) – target PD, based on idealized default table (IDT)
loss_dist (ndarray) – histogram computed from run_stats()
- Returns
cumulative default / loss level at or around 1 - target_pd
- Return type
Notes
Performs an interpolation as pool default/loss distributions can be lumpy
This algorithm was taken from the CLO Asset Model C# code: CalcStats() line 1319
- interpolate_pd_func()¶
Creates an interpolation mapping function for the DBRSM IDT
- Returns
pointer to the interpolation mapping function created in this method
- Return type
function pointer
- run_stats(monte_carlo_loss, securities, transaction, settings, methodology_params)¶
Computes all required statistical values for the simulation results. Last large calculation in the model
- Parameters
monte_carlo_loss (ndarray) – raw simulation results
securities (list[clo_internal_objects.Corp_Loan]) – List of the loans in the pool
transaction (clo_internal_objects.TransactionData) – Data at the transaction (e.g. securitization) level:
settings (clo_internal_objects.ModelSettings) – settings object, e.g. monte carlo seed, number of trials
methodology_params – (clo_internal_objects.MethodologyParamsDefaults): methodology params w.r.t. the default simulation
- Returns
results dict, histograms, cumulative default/loss hurdles, moments, diagnostics
- Return type
Note that an extra element is needed to ensure 100% defaults go into the 100% (not 99%) bucket Also note that we need to convert both the bins & data to float32 to avoid floating point errors when cumulative loss is exact size of a bin (important for lumpy pools)