I was looking for this algorithm (algorithm which will randomly select from a list of elements where each element has different probability of being
Here is the similar code in F#:
let rng = new System.Random() let d = [| "A", 3 "B", 2 "C", 3 |] let sums = Seq.scan (+) 0 (dict d).Values |> Seq.skip 1 |> Seq.toArray let pick = rng.Next(sums.[sums.Length-1]) let res = fst d.[sums |> Seq.findIndex ((<) pick)]