It's not straightforward to test random generators, but this watch expression suggests that Random.weighted is producing a distribution that at least resembles the supplied weights:
> splitmix 42 do
withInitialValue Map.empty do
g = Random.weighted [
(1, '?a),
(2, '?b),
(1, '?c)
]
Each.run do
repeat 1000
Store.modify (Map.putWith (Nat.+) !g 1)
Store.get |> Map.toList
⧩
[(?a, 239), (?b, 502), (?c, 259)]
You can see these here on Share.
It's not straightforward to test random generators, but this watch expression suggests that
Random.weighted
is producing a distribution that at least resembles the supplied weights:Code review