Scheme (Racket) Getting a random boolean with probably 0 < p < 1 -
in racket scheme, best way random boolean true probability 0 <= p <= 1?
here solution, make probabilities explicit:
#lang racket (require math) (define d (discrete-dist '(#t #f) '(0.6 0.4))) (sample d 10) sample output:
'(#f #t #t #t #t #f #t #f #f #t)
Comments
Post a Comment