Tuesday, 15 January 2013

python - Biased coin flipping? -


Between the right and wrong in Python, what is the easiest (not the fastest one) to make a biased random choice ? By "biased", I mean where is the right or wrong where possible on the basis of one truth.

It is very easy and fast:

  imported repared deaf biased flip (prob_true = 0.5): returns random.random () & lt; If you just call  biased_flip ()  then you get  true  and  false  will have 50% probability, but such as  biased_flip ( 0.8)  will give you about eight  true  for each  incorrect  in the long run. 

>

No comments:

Post a Comment