MCPcopy Create free account
hub / github.com/Open-Quant/openquant / inverse_variance_weights

Function inverse_variance_weights

crates/openquant/src/hrp.rs:315–329  ·  view source on GitHub ↗
(cov: &DMatrix<f64>, indices: &[usize])

Source from the content-addressed store, hash-verified

313 let mut std = vec![0.0; n];
314 for i in 0..n {
315 let v = cov[(i, i)];
316 if v <= 0.0 {
317 return Err(HrpError::NoData);
318 }
319 std[i] = v.sqrt();
320 }
321 let mut corr = DMatrix::zeros(n, n);
322 for i in 0..n {
323 for j in 0..n {
324 corr[(i, j)] = cov[(i, j)] / (std[i] * std[j]);
325 }
326 }
327 Ok(corr)
328}
329
330fn corr_to_distances(corr: &DMatrix<f64>) -> DMatrix<f64> {
331 let n = corr.nrows();
332 let mut d = DMatrix::zeros(n, n);

Callers 1

cluster_varianceFunction · 0.70

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected