Skip to content

Instantly share code, notes, and snippets.

@sorenmacbeth
Created February 1, 2012 23:46
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 sorenmacbeth/1720214 to your computer and use it in GitHub Desktop.
Save sorenmacbeth/1720214 to your computer and use it in GitHub Desktop.
(def sample-variance
"Predicate macro that calculates the sample variance of the supplied input
var."
(<- [!val :> !var]
(* !val !val :> !squared)
(c/sum !squared :> !squared-sum)
(c/count !count)
(c/sum !val :> !sum)
(c/avg !val :> !mean)
(* !sum !mean :> !i)
(- !squared-sum !i :> !num)
(- !count 1 :> !denom)
(div !num !denom :> !var)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment