Returns inverse of probabilities for every HNSW level Note that the arg `num_levels` represents HNSW levels, hence level 0 gets implicitly added to the result i.e. if num_levels = 9, then the result will be a vector of size 10 with the last element corresponding to level 0, for which the inverse probability will be 0
(x: f64, num_levels: u8)
| 419 | /// corresponding to level 0, for which the inverse probability will |
| 420 | /// be 0 |
| 421 | pub fn generate_level_probs(x: f64, num_levels: u8) -> Vec<(f64, u8)> { |
| 422 | let mut result = Vec::new(); |
| 423 | for n in (0..=num_levels).rev() { |
| 424 | let first_item = 1.0 - x.powi(-(n as i32)); |
| 425 | let second_item = n; |
| 426 | result.push((first_item, second_item)); |
| 427 | } |
| 428 | result |
| 429 | } |
| 430 | |
| 431 | //typically skips is 1 while near |
| 432 | #[allow(dead_code)] |