In [1]:
    
(require math/statistics
         racket/list)
(define (sbs-hist-vals values [n-bins 15])
  (let* ([sorted-vals (sort values <)]
         [bottom (quantile 0.01 < sorted-vals)]
         [top (quantile 0.99 < sorted-vals)]
         [bin-width (/ (- top bottom) (- n-bins 2))]
         [low (for/list ([b (range n-bins)])
                (if (= b 0)
                    -inf.0
                    (+ bottom (* (- b 1) bin-width))))]
         [high (for/list ([b (range n-bins)])
                (if (= b (- n-bins 1))
                    +inf.0
                    (+ bottom (* b bin-width))))]
         [bin-counts (for/list ([b (range n-bins)])
                 (length (filter (lambda (v) (and (>= v (list-ref low b)) (< v (list-ref high b)))) sorted-vals)))])
     (map (lambda (n) `#(x ,(list-ref bin-counts n))) (range n-bins))))
    
    
    
In [2]:
    
(define xs (repeat (lambda () (normal 0 1)) 100))
(define vs (sbs-hist-vals xs))
vs
    
    Out[2]:
    
    
Now I am explaining all about fish:
$$f = x^{f-s_h}$$.
In [7]:
    
(require plot/pict)
(plot (discrete-histogram vs))
    
    Out[7]:
    
    
In [5]:
    
(define (log-odds p) (- (log p) (log (- 1 p))))
    
    
    
In [6]:
    
(log-odds 0.7)
    
    Out[6]:
    
    
In [13]:
    
(log-odds 0.99)
    
    Out[13]:
    
    
In [14]:
    
(define (logistic x) (/ 1 (+ 1 (exp (- x)))))
    
    
    
In [15]:
    
(logistic 4.5951198501346)
    
    Out[15]:
    
    
In [17]:
    
(define n 9)
(define current-k 4)
(define (p-hat k n) (/ (+ k 0.5) (+ n 1)))
    
    
    
In [30]:
    
(define scale 1)
(define mu (log-odds (p-hat current-k n)))
(define x (normal mu scale))
(define new-k (floor (* (logistic x) (+ 1 n))))
    
    
    
new-k
In [59]:
    
(define (glerb i) (/ (+ (* 0.01 i) 1.1) (+ (* 0.01 i) 1)))
(map glerb '(1 5 10 50 100 1000 5000 10000))
    
    Out[59]:
    
    
In [24]:
    
(logistic (+ mu (normal 0 1)))
    
    Out[24]:
    
    
In [43]:
    
(require gamble/viz)
(hist-pict (repeat (lambda () (normal 0 1)) 10))
    
    Out[43]:
    
    
In [8]:
    
(require plot/pict)
(plot (function sin (- 3) 3))
    
    Out[8]:
    
    
In [ ]: