Guest

Untitled

By: a guest on Jan 27th, 2012  |  syntax: None  |  size: 0.23 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. (defn avg [xs]
  2.   (double (/ (reduce + xs)
  3.              (count xs))))
  4.  
  5. (def *sample-size* 10000)
  6. (defn sample-mean [coin]
  7.   (avg (take *sample-size* coin)))
  8.  
  9. (sample-mean (make-coin 0.3))
  10. ; 0.3036
  11.  
  12. (sample-mean (make-coin 0.7))
  13. ;0.6987