Coin flipping

From Church Wiki
Jump to: navigation, search

This is based on: From mere coincidences to meaningful discoveries, Griffiths, T. L. and Tenenbaum, J. B. (2007); Randomness and coincidences: Reconciling intuition and probability theory, T. L. Griffiths, J. B. Tenenbaum (2001).

(repeated-mh-lex-query 10 25
  '((generator-type (if (flip) 'random 'regular))
    (generator (let ((weight (if (eq? generator-type 'random) 0.5 (beta 1 1))))
                 (lambda () (flip weight)))))
  '(equal? (repeat 5 generator) (list true true true true true)) )

Here is an extension which is able to notice alternating patterns:

 (define (unfold-N N last trans-fn) 
   (let ((next (trans-fn last)))
     (if (= N 0) '() (pair next (unfold-N (- N 1) next trans-fn)))))
 (repeated-tempered-mh-lex-query 25 500
    '((generator-type (if (flip) 'random 'regular))
      (random-generator (lambda (N) (repeat N flip)))
      (sequence-transition (let ((up-weight (beta 0.5 0.5))
                                                     (down-weight (beta 0.5 0.5)))
                                               (lambda (prev) (if prev 
                                                                  (flip up-weight)
                                                                  (flip down-weight)))))
      (sequence-generator (lambda (N) (unfold-N N (flip) sequence-transition)))
      (generator (if (eq? generator-type 'random)
   '(equal? (generator 4) (list true false true false)) )
Personal tools