Created
September 6, 2014 13:36
-
-
Save ktsujister/37cada37a462e0345f06 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns various-distributions.gamma | |
(:require [incanter.charts :as c] | |
[incanter.core :as i] | |
[incanter.distributions :as d] | |
[incanter.stats :as s])) | |
;; https://github.com/incanter/incanter/issues/245 | |
(defn show-gamma-distribution [] | |
(let [dist (d/gamma-distribution 2 2) | |
n 100000 | |
x (repeatedly n #(d/draw dist)) | |
pdf-fn #(d/pdf dist %)] | |
(let [nbins 50 | |
series-label "gamma" | |
[x-min x-max] (s/quantile x :probs [0.01 0.99])] | |
(-> (c/histogram x :nbins nbins :density true :series-label series-label) | |
(c/set-x-range x-min x-max) | |
(c/add-function pdf-fn x-min x-max :series-label series-label) | |
i/view)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment