let distances_to_distribution alphabet a neighbors =
let n1 =
map
(fun (d, _, y) -> (y, 1.0 /. (d +. 0.00001)))
neighbors in
let w_total = fold_left (+.) 0.0 (map snd n1) in
let p_min = a /. (float_of_int (length alphabet)) in
let dist_to_prob distances =
p_min +. (1.0 -. a) *. (float_sum distances) /. w_total in
map
(fun x ->
(x,
dist_to_prob (map snd (filter (fun p -> (fst p) = x) n1))))
alphabet