(define (game1a) (game1 (list-ref '(0 1/2 1) (random 3)))) (define (game1b) (game1 (random))) (define (game1 q) (let ([coin (if (< (random) q) 'head 'tail)]) (display "Bet head, tail, or none: ") (let ([bet (read)]) (let ([payoff (case bet ((none) 1/2) (else (if (eq? coin bet) 1 -1)))]) (display "The coin was ") (display coin) (newline) (display "Your payoff in this round is ") (display payoff) (newline) (game1 q))))) (define (game2a) (game2 (list-ref '(-1 0 1) (random 3)))) (define (game2b) (game2 (normal 0 2))) (define (game2 q) (let ([amount (normal q 1)]) (display "Want to bet? ") (let ([bet (read)]) (let ([payoff (if bet amount 1/2)]) (display "The amount was ") (display amount) (newline) (display "Your payoff in this round is ") (display payoff) (newline) (game2 q))))) ; (normal mean stdev) samples a number from the normal distribution with the ; specified mean and standard deviation. (define (normal mean stdev) (+ mean (* stdev (sqrt (* -2 (log (random)))) (cos (* 8 (atan 1) (random))))))