• (interval a b)

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:100 top

(with-monad state-m
  (defn interval
    [a b]
    "Transform a sequence of uniform random numbers in the interval [0, 1)
     into a sequence of uniform random numbers in the interval [a, b)."
    (let [d (- b a)
	  f (if (zero? a)
	      (if (= d 1)
		identity
		(fn [r] (* d r)))
	      (if (= d 1)
		(fn [r] (+ a r))
		(fn [r] (+ a (* d r)))))]
      (m-fmap f stream-next))))
Vars in clojure.contrib.probabilities.monte-carlo/interval: defn let
Used in 0 other vars

Comments top

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