The binomial distribution

The preceding histogram looks a great deal like a normal distribution, but in fact it is a binomial distribution. The two distributions are very similar, but the binomial distribution is used to model cases where we want to determine how many times a binary event is expected to occur.

Let's plot both the binomial and the normal distribution on a histogram to see how they compare:

(defn ex-4-9 [] (let [passengers (concat (repeat 127 0) (repeat 339 1)) bootstrap (s/bootstrap passengers i/sum :size 10000) binomial (fn [x] (s/pdf-binomial x :size 466 :prob (/ 339 466))) normal (fn [x] (s/pdf-normal x :mean 339 :sd 9.57))] (-> (c/histogram bootstrap :x-label "Female Survivors" :series-label "Bootstrap" :nbins 20 :density true ...

Get Clojure for Data Science now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.