View sample-incanter-plot.clj
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
(use '(incanter core charts io)) | |
;; create points to plot | |
(def x1 (range 0.1 5 0.1)) | |
;; highlight a couple different sets of critical points | |
(def crit-pts1 [0.5 2 3]) | |
(def crit-pts2 [0.25 2.5 3.5]) | |
;; define a reciprocal function | |
(defn reciprocal [x] (div 1 x)) |
View gamma_box_plot.clj
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
(use '(incanter stats charts io)) | |
(doto (box-plot (sample-gamma 1000 :shape 1 :rate 2) | |
:title "Gamma Boxplot" | |
:legend true) | |
(add-box-plot (sample-gamma 1000 :shape 2 :rate 2)) | |
(add-box-plot (sample-gamma 1000 :shape 3 :rate 2)) | |
(add-box-plot (sample-gamma 1000 :shape 5 :rate 1)) | |
(add-box-plot (sample-gamma 1000 :shape 9 :rate 0.5)) | |
clear-background |
View gamma_pdf.clj
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
;; Examples of plots from the Gamma Distribution page at | |
;; Wikipedia (http://en.wikipedia.org/wiki/Gamma_distribution) | |
(use '(incanter stats charts io)) | |
(def x (range 0 20 0.1)) | |
(def gamma-plot (xy-plot x (pdf-gamma x :shape 1 :rate 2) | |
:legend true | |
:title "Gamma PDF" | |
:y-label "Density")) |
View bland_altman_plot.clj
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
(use '(incanter core datasets charts io)) | |
(def flow-meter (to-matrix (get-dataset :flow-meter))) | |
(def x1 (sel flow-meter :cols 1)) | |
(def x2 (sel flow-meter :cols 3)) | |
(doto (bland-altman-plot x1 x2) | |
view | |
clear-background | |
(save "/tmp/bland_altman_plot.png")) |
View trace_plot.clj
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
(use '(incanter core datasets stats bayes charts)) | |
(def survey-data (to-matrix (get-dataset :survey))) | |
(def x (sel survey-data (range 0 2313) (range 1 10))) | |
(def y (sel survey-data (range 0 2313) 10)) | |
(def sample-params (sample-model-params 5000 (linear-model y x :intercept false))) | |
(view (trace-plot (:var sample-params))) | |
(view (trace-plot (sel (:coefs sample-params) :cols 0))) |
View gamma_cdf.clj
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
(use '(incanter stats charts) | |
;; Multi-line plots can be created using Clojure's doto macro | |
(def x (range 0 20 0.1)) | |
(doto (xy-plot x (cdf-gamma x :shape 1 :rate 2) | |
:title "Gamma CDF" | |
:legend true | |
:y-label "Probability") | |
view | |
clear-background |
View gamma_hist.clj
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
(use '(incanter core stats charts io)) | |
;; make a histogram of a sample of 1000 Gamma deviates | |
(doto (histogram (sample-gamma 1000 :shape 1 :rate 2) | |
:title "Gamma Histogram") | |
view | |
clear-background | |
(save "/tmp/gamma_hist.png")) |
View qq_plot.clj
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
(use '(incanter stats charts)) | |
;; qq-plot of normal distributed sample data | |
(view (qq-plot (sample-normal 100))) | |
;; qq-plot of exponential distributed sample data | |
(view (qq-plot (sample-exp 100))) | |
View mvn_scatter_plot.clj
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
(use '(incanter core stats charts)) | |
;; generate a sample from a bi-variate normal distribution | |
(def mvn-samp (sample-mvn 1000 :mean [7 5] :sigma (matrix [[2 1.5] [1.5 3]]))) | |
(def x (sel mvn-samp :cols 0)) | |
(def y (sel mvn-samp :cols 1)) | |
;; add regression line to scatter plot | |
(def lm (linear-model y x)) |
View normal_pdf_plot.clj
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
(use '(incanter stats charts)) | |
;; plot the normal pdf function | |
(def x (range -3 3 0.1)) | |
(view (xy-plot x (pdf-normal x))) |
OlderNewer