jtobin / mwc-probability

A probability distribution type layered on top of mwc-random.
https://hackage.haskell.org/package/mwc-probability
MIT License
8 stars 7 forks source link

Categorical instance to return value rather than index? #18

Closed baskaransri closed 4 years ago

baskaransri commented 4 years ago

I'd quite like if there was an analogue of categorical like:

discrete :: (Foldable f, PrimMonad m) => f (Double, a) -> Prob m a

which would sample from the container, choosing each a with the associated probability.

jtobin commented 4 years ago

I have an unequal probability sampling implementation in a slightly less well-known library called sampling (see psample, presample), but I agree an implementation would be nice here too. I'll add it.