<a id="skfolio-uncertainty-set-compactcovarianceuncertaintyset"></a>

# skfolio.uncertainty_set.CompactCovarianceUncertaintySet

<a id="skfolio.uncertainty_set.CompactCovarianceUncertaintySet"></a>

### *class* skfolio.uncertainty_set.CompactCovarianceUncertaintySet(radius, metric_sqrt, basis)

Compact representation of a quadratic covariance uncertainty penalty.

This object stores the data needed to evaluate a worst-case variance penalty in
reduced projection form, without materializing the equivalent dense positive
semidefinite matrix.

Let $C$ be a diagonal metric square root and let $Q$ be an orthonormal
basis. For portfolio weights $w$, the optimizer evaluates

$$
\kappa \min_z \lVert C w - Q z \rVert_2^2.
$$

This is equivalent to adding the following positive semidefinite matrix to the
quadratic variance term:

$$
\kappa C^\top (I - Q Q^\top) C.
$$

The compact representation avoids building this dense matrix. The optimizer only
needs the diagonal entries of $C$ and the basis $Q$.

* **Parameters:**
  **radius** *float*
  : Non-negative multiplier $\kappa$ applied to the quadratic covariance
    penalty.

  **metric_sqrt** *ndarray of shape (n_assets,)*
  : Diagonal of the metric square root $C$.

  **basis** *ndarray of shape (n_assets, rank)*
  : Orthonormal basis $Q$ of the subspace projected out by the quadratic
    penalty.
* **Attributes:**
  **radius** *float*
  : Non-negative multiplier $\kappa$.

  **metric_sqrt** *ndarray of shape (n_assets,)*
  : Diagonal of the metric square root $C$.

  **basis** *ndarray of shape (n_assets, rank)*
  : Orthonormal basis $Q$.

