<a id="skfolio-measures-expected-max-sharpe-ratio"></a>

# skfolio.measures.expected_max_sharpe_ratio

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

### skfolio.measures.expected_max_sharpe_ratio(n_trials, trial_sharpe_ratio_std, trial_sharpe_ratio_mean=0.0)

Approximate the expected maximum Sharpe ratio across independent trials.

When a strategy is selected as the best of several trials, its Sharpe ratio is
the maximum of a sample and is therefore inflated by the selection itself.

The formula below approximates this expected maximum. It assumes that the
trial Sharpe ratios are independent and follow the same normal distribution:

$$
SR_0 = \mu + \sigma \left[(1 - \gamma) \, Z^{-1}\left(1 -
\frac{1}{N}\right) + \gamma \, Z^{-1}\left(1 - \frac{1}{N e}\right)\right]
$$

with $N$ the number of trials, $\mu$ and $\sigma$ the mean
and standard deviation of the trial Sharpe ratios, $\gamma$ the
Euler-Mascheroni constant, $e$ Euler’s number and $Z^{-1}$ the
inverse standard normal CDF.

The Deflated Sharpe Ratio uses this benchmark with $\mu = 0$,
representing trials whose true Sharpe ratios are zero.

* **Parameters:**
  **n_trials** *float*
  : Number of independent trials $N$, which can be fractional when
    estimated as an effective trial count. Must be finite and at least 1.

  **trial_sharpe_ratio_std** *float*
  : Standard deviation $\sigma$ of the trial Sharpe ratios, measuring
    how much they vary from one trial to another. Must be finite and
    non-negative.

  **trial_sharpe_ratio_mean** *float, default=0.0*
  : Mean $\mu$ of the Sharpe ratios across the trials.
* **Returns:**
  **value** *float*
  : Approximate expected maximum Sharpe ratio, in the same per-period terms
    as `trial_sharpe_ratio_std` and `trial_sharpe_ratio_mean`.
* **Raises:**
  ValueError
  : If `n_trials` is not a finite real number greater than or equal to 1, or
    `trial_sharpe_ratio_std` is not a finite, non-negative real number.

#### SEE ALSO
[`probabilistic_sharpe_ratio`](https://skfolio.org/generated/skfolio.measures.probabilistic_sharpe_ratio.html.md#skfolio.measures.probabilistic_sharpe_ratio)

[`deflated_sharpe_ratio`](https://skfolio.org/generated/skfolio.measures.deflated_sharpe_ratio.html.md#skfolio.measures.deflated_sharpe_ratio)

### Notes

With a single trial or without dispersion across trials, there is no selection
to correct for and `trial_sharpe_ratio_mean` is returned.

The calculation treats all `n_trials` trials as independent. Similar parameter
settings can produce correlated Sharpe ratios, so counting every setting as an
independent trial can overestimate the expected maximum. An estimated effective
number of independent trials can be passed as `n_trials`.

### References

* <a id='r41e9b0a6f75f-1'>**[1]**</a> “The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting, and Non-Normality”. Bailey, D. and Lopez de Prado, M. (2014)

