[CM] small contribution to Op.2, No. 5: Chance and Probability
Terrence Brannon
terry at hcoop.net
Wed Oct 6 01:54:08 PDT 2004
When I saw this expression:
(chance? .75)
I got very curious and decided to see how close the percentage of true values
would be to 75% based on the number of trials I ran, so I wrote this
Scheme-specific code to check it out:
(use-modules (srfi srfi-1))
(define (percent success trials)
(* 100
(/ success trials)))
(define *chance* 0.75)
(define (try-chance trials chance)
(let* ((dummy-list (make-list trials))
(trial-result (loop for tmp in dummy-list collect (chance? chance))))
(percent (count (lambda (x) x) trial-result)
trials)))
(define (trial-stats)
(let* ((powers-of-2 (iota 16 0 1)))
(loop for power in powers-of-2 collect (try-chance (expt 2 power)
*chance*))))
(trial-stats)
==
some of the early experimental results are right on the theoretical, but some
are way off. only after many trials do we consistently get the experimental and
theoretical close, as we expected.
well, I had some fun with this :)
--
Terrence Brannon, terry at hcoop.net
More information about the Cmdist
mailing list