- [Function]
(
odds
prob [true] [false] [state])
Returns true if a randomly generated number is less
than prob, otherwise false. The default values
for true and false are boolean true and false,
respectively. state is a random state object and defaults
to *random-state*
Examples:
Example 1. The odds
function.
(odds .5) #f (odds .5 60) 60 (odds 1) ⇒ #t (odds 0 'win) ⇒ #f (odds .2 "Yup" "Nope") ⇒ "Nope"
Example 2. Play octaves with increasing probability.
(define (play-octs reps lb ub) ;; no octaves at start all at end (process with env = '(0 0 .1 0 .8 .75 1 1) for i below reps ;; probability of adding octave for p = (interpl (/ i reps) env) for k = (between lb ub k) for r = (odds .3 .4 .2) output (new midi :time (now) :keynum k :duration (* r 1.5)) when (odds p) output (new midi :time (now) :keynum (+ k 12) :duration (* r 1.5)) wait r)) (events (play-octs 60 60 80) "test.mid") ⇒ "test.mid"