Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Commit

Permalink
Replaced beta with rate for exponential distribution.
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp committed Apr 16, 2012
1 parent 389279f commit e24df07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/package.lisp
Expand Up @@ -43,7 +43,7 @@
#:left
#:right
#:r-exponential
#:beta
#:rate
#:draw-standard-exponential
#:r-normal
#:mean
Expand Down
22 changes: 11 additions & 11 deletions src/univariate.lisp
Expand Up @@ -46,28 +46,28 @@ which has density exp(-x)."

(declaim (inline draw-standard-exponential))

(define-rv r-exponential (beta)
(define-rv r-exponential (rate)
(:documentation "Exponential(beta) distribution, with density
beta*exp(-beta*x) on x >= 0.")
((beta :type double-float :reader t))
(with-doubles (beta)
(assert (plusp beta))
(make :beta beta))
(mean () (/ beta))
(variance () (expt beta -2))
((rate :type double-float :reader t))
(with-doubles (rate)
(assert (plusp rate))
(make :rate rate))
(mean () (/ rate))
(variance () (expt rate -2))
(log-pdf (x &optional ignore-constant?)
(declare (ignore ignore-constant?))
(with-doubles (x)
(- (log beta) (* beta x))))
(- (log rate) (* rate x))))
(cdf (x)
(with-doubles (x)
(- 1 (exp (- (* beta x))))))
(- 1 (exp (- (* rate x))))))
(quantile (p)
(with-doubles (p)
(check-probability p :right)
(/ (log (- 1 p)) (- beta))))
(/ (log (- 1 p)) (- rate))))
(draw (&key)
(/ (draw-standard-exponential) beta)))
(/ (draw-standard-exponential) rate)))


;;; Normal distribution (univariate).
Expand Down

0 comments on commit e24df07

Please sign in to comment.