mardi 21 avril 2020

How to get a list of booleans where the true values follow a bernoulie distribution

Currently I have some haskell code that requires a random list Boolean values. Currently I am following the approach in the book (Learn you a haskell) which is

list = randoms someStdGen :: [Bool]

However this is no good for me as the previous list will have about the same number of Falses and Trues.

What is the best way to get a list so that, for example, only about 1/4 of the elements are True.




Aucun commentaire:

Enregistrer un commentaire