// Select the first sorted value index whose cumulative nonnegative weight reaches half the total. Zero total returns minus one. pub fn weighted_median_pos(weights: vector) -> i64 { let mut sum = 0.0; let mut i = 0; while i= sum { return i; } i += 1; } return -1; }