Skip to content

Instantly share code, notes, and snippets.

David Edgar Liebke liebke

Block or report user

Report or block liebke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View incanter-excel.clj
(use '(incanter core charts excel))
;; read .xls file of Australian airline passenger data from the 1950s.
(with-data (read-xls "")
(view $data)
;; time-series-plot needs time in millisecs
;; create a function, to-millis, to convert a sequence of Date objects
;; to a sequence of milliseconds
(let [to-millis (fn [dates] (map #(.getTime %) dates))]
(view (time-series-plot (to-millis ($ :date)) ($ :passengers)))))
View infix_examples.clj
(use 'incanter.core)
;; basic arithmetic
($= 7 + 8 - 2 * 6 / 2) ; => 9
;; add 5 to each element of the vector [1 2 3]
($= [1 2 3] + 5) ; => (6 7 8)
View repl.bat
@echo off
setLocal EnableDelayedExpansion
for /R ./lib %%a in (*.jar) do (
set CLASSPATH=%CLASSPATH%;src;test;config;data
java -Xmx1G -cp %CLASSPATH% jline.ConsoleRunner clojure.main -e "(use '[ :only (spit read-lines reader writer)] '[clojure.contrib def ns-utils pprint repl-utils shell-out]) (require '[clojure.contrib.str-utils2 :as s])" -r
View simple_interaction.clj
(use '(incanter core processing))
;; simple interactive Processing example taken from website:
;; set up variable references to use in the sketch object
(let [radius (ref 50.0)
X (ref nil)
Y (ref nil)
View bootstrap_median.clj
;; example with smoothing
;; Newcomb's speed of light data
(use '(incanter core stats charts))
;; A numeric vector giving the Third Series of measurements of the
;; passage time of light recorded by Newcomb in 1882. The given
;; values divided by 1000 plus 24 give the time in millionths of a
;; second for light to traverse a known distance. The 'true' value is
View bayes_multinomial.clj
;; Bayesian inference of multinomial distribution parameters
(use '(incanter core stats bayes charts))
(def y [727 583 137])
(div y 1447.) ;; (0.502 0.403 0.095)
View monty_hall.clj
;; Monty Hall problem (Let's Make a Deal gameshow)
(use '(incanter core stats charts))
;; set a simulation sample size
(def n 10000)
;; generate samples of initial-guesses, prize-doors, and switch decisions
(def initial-guesses (sample [1 2 3] :size n))
(def prize-doors (sample [1 2 3] :size n))
View benford_iran.clj
;; Chi-square goodness-of-fit analysis of 2009 Iranian election and Benford's law
(use '(incanter core stats charts io))
(def votes (read-dataset "data/iran_election_2009.csv"
:header true))
(view votes)
(def regions (sel votes :cols "Region"))
View means_permutation.clj
;; significance testing with randomization
(use '(incanter core stats datasets charts))
(def data (to-matrix (get-dataset :plant-growth)))
;; Break the first column of the data into groups based on
;; treatment type (second column) using the group-by function.
(def groups (group-by data 1 :cols 0))
(t-test (first groups) :y (second groups))
View chisq_test.clj
;; Chi-square test of independence:
;; testing the independence of eye and hair color
;; for both males and females
(use '(incanter core stats charts datasets))
(def by-gender (group-by (get-dataset :hair-eye-color) 2))
(def male-data (first by-gender))
(view male-data)
You can’t perform that action at this time.