<a id="skfolio-measures-cvar"></a>

# skfolio.measures.cvar

<a id="skfolio.measures.cvar"></a>

### skfolio.measures.cvar(returns, beta=0.95, sample_weight=None)

Compute the historical CVaR (conditional value at risk).

The CVaR (or Tail VaR) represents the mean shortfall at a specified confidence
level (beta).

* **Parameters:**
  **returns** *ndarray of shape (n_observations,) or (n_observations, n_assets)*
  : Array of return values.

  **beta** *float, default=0.95*
  : The CVaR confidence level (expected VaR on the worst (1-beta)% observations).

  **sample_weight** *ndarray of shape (n_observations,), optional*
  : Sample weights for each observation. If None, equal weights are assumed.
* **Returns:**
  **value** *float or ndarray of shape (n_assets,)*
  : CVaR.
    If `returns` is a 1D-array, the result is a float.
    If `returns` is a 2D-array, the result is a ndarray of shape (n_assets,).

### Notes

NaN handling:
- Unweighted: NaNs are ignored; all-NaN inputs yield NaN.
- Weighted: NaNs propagate.

