<a id="skfolio-utils-stats-safe-cholesky"></a>

# skfolio.utils.stats.safe_cholesky

<a id="skfolio.utils.stats.safe_cholesky"></a>

### skfolio.utils.stats.safe_cholesky(covariance, ridge_scale=1e-12, max_tries=3)

Compute a Cholesky factor $L$ from covariance $\Sigma$.

Fast path: try plain Cholesky on the input as-is.
Fallback: symmetrize and add ridge $\lambda I$ with escalation until SPD:

$$
\Sigma_{reg} = (\Sigma + \Sigma^T)/2 + \lambda I \approx L L^T

$$

* **Parameters:**
  **covariance** *ndarray of shape (n_assets, n_assets)*
  : Covariance matrix $\Sigma$.

  **ridge_scale** *float, default=1e-12*
  : Relative ridge size, as a fraction of the average absolute covariance
    diagonal. If that scale is zero, a positive numerical floor is used.

  **max_tries** *int, default=3*
  : Maximum number of ridge escalations before raising an error.
* **Returns:**
  **chol** *ndarray of shape (n_assets, n_assets)*
  : Lower triangular Cholesky factor $L$ such that
    $\Sigma \approx L L^T$.
* **Raises:**
  ValueError
  : If Cholesky decomposition fails after all retry attempts.

