Given weights w and the covariance matrix covariance of a random vector
, return .
The off-diagonal terms are the point: correlated inputs can make a portfolio or an ensemble far riskier than summing individual variances suggests.
Input
w = [0.5, 0.5]
covariance = [[1.0, 0.0], [0.0, 1.0]]
Output
0.5