Created
September 6, 2014 14:15
-
-
Save ktsujister/9f57be169f6b3222e749 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 more-distributions.cauchy | |
(:require [incanter-contrib.distributions :as icd] | |
[incanter.charts :as c] | |
[incanter.core :as i] | |
[incanter.distributions :as d] | |
[incanter.stats :as s])) | |
(defn show-cauchy-distribution [] | |
(let [dist (icd/cauchy-distribution 0 1) | |
n 100000 | |
x (->> (repeatedly n #(d/draw dist)) | |
(filter (fn [x] (and (> x -10) | |
(< x 10))))) | |
pdf-fn #(d/pdf dist %)] | |
(let [nbins 50 | |
series-label "cauchy" | |
[x-min x-max] [-10 10]] | |
(-> (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 "cauchy-pdf") | |
i/view)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment