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

# skfolio.uncertainty_set.EmpiricalMuUncertaintySet

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

### *class* skfolio.uncertainty_set.EmpiricalMuUncertaintySet(prior_estimator=None, confidence_level=0.95, diagonal=True, n_eff=None)

Empirical Mu Uncertainty Set.

Compute the expected returns ellipsoidal uncertainty set [[1]](#r9d3b3fa25b42-1):

$$
U_{\mu}
=
\left\{
    \mu :
    (\mu - \hat{\mu})^\top S^{-1}(\mu - \hat{\mu})
    \le \kappa^2
\right\}.
$$

Under the assumption that $\Sigma$ is given, the distribution of the sample
estimator $\hat{\mu}$ based on an i.i.d. sample
$R_{t}\sim N(\mu, \Sigma), t=1,...,T$ is given by
$\hat{\mu}\sim N(\mu, \frac{1}{T}\Sigma)$.

The radius of the ellipsoid $\kappa$ (confidence region) is computed using:

$$
\kappa^2 = \chi^2_{n_{\text{assets}}}(\beta)

$$

with $\chi^2_{n_{\text{assets}}}(\beta)$ the inverse cumulative distribution
function of the chi-squared distribution with $n_{\text{assets}}$ degrees of
freedom at the $\beta$ confidence level.

The shape matrix $S$ of the ellipsoid is computed using:

$$
S = \frac{1}{T}\Sigma

$$

with the option to force the non-diagonal elements of the covariance matrix to zero.
The estimator stores the square-root factor as the linear geometry map
$L = S^{1/2}$.

* **Parameters:**
  **prior_estimator** *BasePrior, optional*
  : The [prior estimator](https://skfolio.org/user_guide/prior.html.md#prior) used to estimate the assets covariance
    matrix. The default (`None`) is to use [`EmpiricalPrior`](https://skfolio.org/generated/skfolio.prior.EmpiricalPrior.html.md#skfolio.prior.EmpiricalPrior).

  **confidence_level** *float, default=0.95*
  : Confidence level $\beta$ of the inverse cumulative distribution function
    of the chi-squared distribution. The default value is `0.95`.

  **diagonal** *bool, default=True*
  : If `True`, the non-diagonal elements of the covariance matrix are set to zero.

  **n_eff** *float, optional*
  : Effective number of observations used for the mean estimator. If `None`,
    the number of observations in `X` is used. This is useful when the expected
    returns are estimated using a different window length or a weighted estimator
    (e.g. EWMA), in which case `n_eff` should be set to the corresponding effective
    sample size.
* **Attributes:**
  **uncertainty_set_** *UncertaintySet*
  : Mu Uncertainty set [`UncertaintySet`](https://skfolio.org/generated/skfolio.uncertainty_set.UncertaintySet.html.md#skfolio.uncertainty_set.UncertaintySet).

  **prior_estimator_** *BasePrior*
  : Fitted `prior_estimator`.

  **n_eff_** *float*
  : Effective number of observations actually used to build the uncertainty set.

### Methods

| [`fit`](#skfolio.uncertainty_set.EmpiricalMuUncertaintySet.fit)(X[, y])            | Fit the Empirical Mu Uncertainty set estimator.   |
|-------------------------------------------------------------------------|---------------------------------------------------|
| [`get_metadata_routing`](#skfolio.uncertainty_set.EmpiricalMuUncertaintySet.get_metadata_routing)() | Get metadata routing of this object.              |
| [`get_params`](#skfolio.uncertainty_set.EmpiricalMuUncertaintySet.get_params)([deep])     | Get parameters for this estimator.                |
| [`set_params`](#skfolio.uncertainty_set.EmpiricalMuUncertaintySet.set_params)(\*\*params) | Set the parameters of this estimator.             |

### References

* <a id='r9d3b3fa25b42-1'>**[1]**</a> “Robustness properties of mean-variance portfolios”, Optimization: A Journal of Mathematical Programming and Operations Research, Schöttle & Werner (2009).
* <a id='r9d3b3fa25b42-2'>**[2]**</a> “Portfolio Optimization: Theory and Application”, Chapter 14, Daniel P. Palomar (2025)

<a id="skfolio.uncertainty_set.EmpiricalMuUncertaintySet.fit"></a>

#### fit(X, y=None, \*\*fit_params)

Fit the Empirical Mu Uncertainty set estimator.

* **Parameters:**
  **X** *array-like of shape (n_observations, n_assets)*
  : Price returns of the assets.

  **y** *array-like of shape (n_observations, n_factors), optional*
  : Price returns of factors.
    The default is `None`.

  **\*\*fit_params** *dict*
  : Parameters to pass to the underlying estimators.
    Only available if `enable_metadata_routing=True`, which can be
    set by using `sklearn.set_config(enable_metadata_routing=True)`.
    See [Metadata Routing User Guide](https://skfolio.org/user_guide/metadata_routing.html.md#metadata-routing) for
    more details.
* **Returns:**
  **self** *EmpiricalMuUncertaintySet*
  : Fitted estimator.

<a id="skfolio.uncertainty_set.EmpiricalMuUncertaintySet.get_metadata_routing"></a>

#### get_metadata_routing()

Get metadata routing of this object.

Please check [User Guide](https://skfolio.org/user_guide/metadata_routing.html.md#metadata-routing) on how the routing
mechanism works.

* **Returns:**
  **routing** *MetadataRequest*
  : A `MetadataRequest` encapsulating
    routing information.

<a id="skfolio.uncertainty_set.EmpiricalMuUncertaintySet.get_params"></a>

#### get_params(deep=True)

Get parameters for this estimator.

* **Parameters:**
  **deep** *bool, default=True*
  : If True, will return the parameters for this estimator and
    contained subobjects that are estimators.
* **Returns:**
  **params** *dict*
  : Parameter names mapped to their values.

<a id="skfolio.uncertainty_set.EmpiricalMuUncertaintySet.set_params"></a>

#### set_params(\*\*params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects
(such as `Pipeline`). The latter have
parameters of the form `<component>__<parameter>` so that it’s
possible to update each component of a nested object.

* **Parameters:**
  **\*\*params** *dict*
  : Estimator parameters.
* **Returns:**
  **self** *estimator instance*
  : Estimator instance.

