• (make-distribution coll f)
Returns the distribution in which each element x of the collection
has a probability proportional to (f x)

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/finite_distributions.clj:134 top

(defn make-distribution
  "Returns the distribution in which each element x of the collection
   has a probability proportional to (f x)"
  [coll f]
  (normalize (into {} (for [k coll] [k (f k)]))))
Vars in clojure.contrib.probabilities.finite-distributions/make-distribution: defn for into
Used in 0 other vars

Comments top

No comments for make-distribution. Log in to add a comment.