tweag / monad-bayes

A library for probabilistic programming in Haskell.
MIT License
407 stars 62 forks source link

Add Alternative instance to Population #244

Open turion opened 1 year ago

turion commented 1 year ago

One could easily derive Alternative for Population. It would have the effect of concatenating several particle populations.

For example, (spawn 100 >> model1) <|> (spawn 100 >> model2) would have 200 particles, where 100 have been conditioned according to the first model, and the others according to the second model.

Another useful function might be take :: Int -> Population -> Population which makes sure at most a certain number of particles are in the filter. Probably, the ones with the lowest mass should be dropped.