Return Standardization Baseline
Problem Statement
A common variance-reduction trick standardizes the batch of returns before using them as weights:
where mu and sigma are the mean and (population) standard deviation of the returns, and epsilon guards against divide-by-zero. Implement standardize_returns(returns, eps) returning the standardized list.
Example
standardize_returns([1.0, 2.0, 3.0], 1e-8)
[-1.2247, 0.0, 1.2247]
- Calculate the mean () of the returns to determine the center of the distribution: .
- Compute the population variance by averaging the squared deviations from the mean: .
- Determine the standard deviation () by taking the square root of the variance: .
- Standardize each return value by subtracting the mean and dividing by the sum of the standard deviation and the epsilon guard (), which is effectively just :
- For :
- For :
- For :
- The final output is [-1.2247, 0.0, 1.2247]
Constraints
len(returns) >= 1.- Use the population standard deviation (divide by N).
- Return a list of floats.