Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow negative exponential distributions (fixes #835) #836

Merged
merged 4 commits into from Feb 6, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion librandom/exp_randomdev.h
Expand Up @@ -40,7 +40,9 @@ namespace librandom
Name: rdevdict::exponential - exponential random deviate generator
Description: Generates exponentially distributed random numbers.

p(x) = lambda exp(-lambda*x), x >= 0.
p(x) = lambda exp(-lambda*x), x >= 0 if lambda > 0
p(x) = -lambda exp(-lambda*x), x <= 0 if lambda < 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would write this differently for clarity: Add a sentence above pointing out explicitly that negative lambda are permitted and then yield negative numbers, and then

For lambda < 0:
  p(x) = 0 for x >= 0
  p(x) = |lambda| exp ( -|lambda| |x| ) for x < 0

Since we are coercing the usual notation here, we should be pretty explicit. Ideally, we would want to draw a positive x and then multiply that with -1, but that will only become possible in the future (see #488 for ideas under consideration).



Parameters:
lambda - rate parameter (default: 1.0)
Expand Down