Function
inverse_variance_weights
(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 | |
| 330 | fn corr_to_distances(corr: &DMatrix<f64>) -> DMatrix<f64> { |
| 331 | let n = corr.nrows(); |
| 332 | let mut d = DMatrix::zeros(n, n); |
Tested by
no test coverage detected