Skip to content

Instantly share code, notes, and snippets.

@ktsujister
Created August 30, 2014 10:09
Show Gist options
  • Save ktsujister/f8197a3f18f9857e4be8 to your computer and use it in GitHub Desktop.
Save ktsujister/f8197a3f18f9857e4be8 to your computer and use it in GitHub Desktop.
(ns various-distributions.uniform
(:require [incanter.charts :as c]
[incanter.core :as i]
[incanter.distributions :as d]))
(defn show-uniform-distribution []
(let [dist (d/uniform-distribution 0.0 1.0)
n 10000
x (repeatedly n #(d/draw dist))
pdf-fn #(d/pdf dist %)]
(let [nbins 50
series-label "uniform"]
(-> (c/histogram x :nbins nbins :density true :series-label series-label)
(c/add-function pdf-fn 0 1 :series-label "uniform-pdf")
i/view))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment