Skip to content

Instantly share code, notes, and snippets.

@tutysara
Created September 5, 2012 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tutysara/3638556 to your computer and use it in GitHub Desktop.
Save tutysara/3638556 to your computer and use it in GitHub Desktop.
(def alldata (io/read-dataset "alldata.csv"))
(defn normalize
"Normalizes data"
[dataseq]
(let [mean (stats/mean dataseq)
normalfn (fn [x] (/ (- x mean) mean))]
(map normalfn dataseq)))
(def plot(-> (charts/xy-plot (range 180) (incanter/sel alldata :cols 0))
(charts/add-lines (range 180) (incanter/sel alldata :cols 1))
(charts/add-lines (range 180) (incanter/sel alldata :cols 2))
(charts/add-lines (range 180) (incanter/sel alldata :cols 3))
(charts/add-lines (range 180) (incanter/sel alldata :cols 4))
(charts/add-lines (range 180) (incanter/sel alldata :cols 5))
(charts/add-lines (range 180) (incanter/sel alldata :cols 6))
(charts/clear-background)))
(incanter/view plot)
(def normalized-plot
(-> (charts/xy-plot (range 180) (normalize (incanter/sel alldata :cols 0)))
(charts/add-lines (range 180) (normalize (incanter/sel alldata :cols 1)))
(charts/add-lines (range 180) (normalize (incanter/sel alldata :cols 2)))
(charts/add-lines (range 180) (normalize (incanter/sel alldata :cols 3)))
(charts/add-lines (range 180) (normalize (incanter/sel alldata :cols 4)))
(charts/add-lines (range 180) (normalize (incanter/sel alldata :cols 5)))
(charts/add-lines (range 180) (normalize (incanter/sel alldata :cols 6)))
(charts/clear-background)))
(incanter/view normalized-plot)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment