Skip to content

Instantly share code, notes, and snippets.

@liebke
Created April 21, 2009 13:56
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 liebke/99153 to your computer and use it in GitHub Desktop.
Save liebke/99153 to your computer and use it in GitHub Desktop.
(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))
;; plot scatter-plot of points
(doto (scatter-plot x y)
view
(add-lines x (:fitted lm)))
@dfarmer
Copy link

dfarmer commented Jul 4, 2010

One small change needed to run this on current Incanter: Replace sample-multivariate-normal with sample-mvn

@liebke
Copy link
Author

liebke commented Jul 4, 2010

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment