(defn binomial
[n p]
"Returns the binomial distribution, which is the distribution of the
number of successes in a series of n experiments whose individual
success probability is p."
(let [q (- 1 p)
n1 (inc n)
k (range n1)
pk (take n1 (iterate #(* p %) 1))
ql (reverse (take n1 (iterate #(* q %) 1)))
f (bc n)]
(into {} (map vector k (map * f pk ql)))))
Comments top
No comments for binomial. Log in to add a comment.