#426easyRisk
Ledoit-Wolf Shrinkage
Time Limit: 2sMemory: 256MB
Problem
In high-dimensional portfolio management, the sample covariance matrix is noisy and can be singular. Ledoit-Wolf shrinkage stabilizes it by blending with a structured target:
Given a 2x2 sample covariance matrix , a shrinkage target , and the optimal shrinkage intensity , compute the shrunk covariance matrix.
Input Format
Three lines:
- Line 1: four floats
s11 s12 s21 s22(sample covariance, row-major) - Line 2: four floats
f11 f12 f21 f22(shrinkage target, row-major) - Line 3: one float
alpha(shrinkage intensity)
Output Format
Three space-separated values: c11 c12 c22 (the 3 unique elements of the symmetric shrunk matrix), each to 4 decimal places.
Examples
Example 1
Input(Three lines:)
0.04 0.01 0.01 0.09 0.04 0.0 0.0 0.09 0.3
Output
0.0400 0.0070 0.0900
c11 = 0.3*0.04 + 0.7*0.04 = 0.04. c12 = 0.3*0 + 0.7*0.01 = 0.007. c22 = 0.3*0.09 + 0.7*0.09 = 0.09.
Example 2
Input(Three lines:)
0.10 0.03 0.03 0.08 0.05 0.0 0.0 0.05 0.5
Output
0.0750 0.0150 0.0650
c11 = 0.5*0.05 + 0.5*0.10 = 0.075. c12 = 0.5*0 + 0.5*0.03 = 0.015. c22 = 0.5*0.05 + 0.5*0.08 = 0.065.
Constraints
- •4 space-separated floats for sample covariance (row-major 2x2): s11 s12 s21 s22
- •4 space-separated floats for shrinkage target (row-major 2x2): f11 f12 f21 f22
- •1 float for shrinkage intensity alpha in [0, 1]
- •Output 3 unique elements (c11 c12 c22) to 4 decimal places
Loading interactive editor…