(lambda (seed) (let ((U (((fileVal "RC4") seed) 'U)) (l2 (/ (log 2)))) (let ((f 0) (b -1)) (lambda (p) (if (< b 0) (begin (set! f (U)) (set! b 53))) (let ((a (< f p))) (if a (begin (set! f (/ f p)) (set! b (+ b (* l2 (log p))))) (let ((C (- 1 p))) (set! f (/ (- f p) C)) (set! b (+ b (* l2 (log C)))))) a))))) ; This uses arithmetic coding theory and b measures remaining entropy in f. ; It is hard to make precise claims about it. ; It is thus slovenly. It is a little more efficient of entropy than bCoin. ; f is uniformly distributed between 0 and 1 or b<0 after each new decision. ; tests: same as for bCoin but renaming testee as bCoin2 (let ((ac ((fileVal "bCoin2") "Floss"))(b 0.1)(t 0)) (((fileVal "Do") 'Do) 1000000 (lambda (_) (if (ac b) (set! t (+ t 1))))) t) ; => 100087 (let ((ac ((fileVal "bCoin2") "Flsr"))) (let q ((n 1000000) (s 0)) (if (= n 0) s (q (- n 1) (if (ac 0.3) (+ s 1) s))))) ; => 300395 (let ((ac ((fileVal "bCoin2") "Flsr")) (sz 1000000)) (let q ((n sz) (s 0) (t 0)) (if (= n 0) (cons s t) (if (ac (/ n sz)) (q (- n 1) (+ s 1) (+ t n)) (q (- n 1) s t))))) ; => (500492 . 333606633480) (let ((ac ((fileVal "bCoin2") "Flyr")) (sz 1000000) (p 3/11)) (let q ((s 0)(n sz)) (if (= n 0) (list sz s (+ 0.0 p)) (q (if (ac p) (+ s 1) s) (- n 1))))) ; => (1000000 272706 0.2727272727272727)