Skip to content

Instantly share code, notes, and snippets.

@bryanl
Created November 27, 2012 19:49
Show Gist options
  • Select an option

  • Save bryanl/4156559 to your computer and use it in GitHub Desktop.

Select an option

Save bryanl/4156559 to your computer and use it in GitHub Desktop.
(defn normal->beta [n,mean,sd,min,max]
(let [range (- max min)
m (/ (- mean min) range)
s (/ sd range)
a (/ (- (* m m) (* m m m) (* m (* s s))) (* s s))
b (/ (+ m (* -2 m m) (* m m m) (- 0 (* s s) (* m s s))) (* s s))
data (list (incanter-stats/sample-beta n :alpha a :beta b))]
(map (fn [d] (+ min (* d range))) (flatten data))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment