Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created June 7, 2015 09:48
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 shigemk2/53e598c3180287bd6f63 to your computer and use it in GitHub Desktop.
Save shigemk2/53e598c3180287bd6f63 to your computer and use it in GitHub Desktop.
(defun square(x) (* x x))
(setq avg (/ (+ 0.0 2.0 8.0) 3))
(setq var (/ (+ (square (- 2 avg)) (square (- 8 avg)) (square (- 0 avg))) 3))
(print var)
(defun variance4 (a b c d)
(defun square(x) (* x x))
(setq average (/ (+ a b c d) 4))
(/ (+ (square (- a average)) (square (- b average)) (square (- c average)) (square (- d average))) 4))
(variance4 0.0 2.0 8.0 16.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment