1.2.0 permalink Arrow_down_16x16
  • (exponential lambda)
Transform a sequence of uniform random numbers in the interval [0, 1)
into a sequence of exponential random numbers with parameter lambda.

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

(with-monad state-m
  (defn exponential
    "Transform a sequence of uniform random numbers in the interval [0, 1)
     into a sequence of exponential random numbers with parameter lambda."
    [lambda]
    (when (<= lambda 0)
      (throw (IllegalArgumentException.
  	    "exponential distribution requires a positive argument")))
    (let [neg-inv-lambda (- (/ lambda))
	  ; remove very small numbers to prevent log from returning -Infinity
	  not-too-small  (reject #(< % 1e-323) stream-next)]
      (m-fmap #(* (. Math log %) neg-inv-lambda) not-too-small))))
Vars in clojure.contrib.probabilities.monte-carlo/exponential: * <= defn let when
Used in 0 other vars

Comments top

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