1.2.0 permalink Arrow_down_16x16
  • (discrete dist)
A discrete distribution, defined by a map dist mapping values
to probabilities. The sum of probabilities must be one.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/probabilities/monte_carlo.clj:87 top

(with-monad state-m
  (defn discrete
    "A discrete distribution, defined by a map dist mapping values
     to probabilities. The sum of probabilities must be one."
    [dist]
    (letfn [(pick-at-level [l dist-items]
	      (let [[[x p] & rest-dist] dist-items]
		(if (> p l)
		  x
		  (recur (- l p) rest-dist))))]
      (m-fmap #(pick-at-level % (seq dist)) stream-next))))
Vars in clojure.contrib.probabilities.monte-carlo/discrete: defn letfn seq
Used in 0 other vars

Comments top

No comments for discrete. Log in to add a comment.