-
Notifications
You must be signed in to change notification settings - Fork 900
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
Is Mean for NegativeBinomial distribution correct? #455
Comments
That looks suspicious, thanks for reporting! |
It turns out the mean is correct, but the samples return the number of trials (for reaching r successes) instead of the number of failures (until r successes are reached). Both are common definitions of the distribution, but they of course should be consistent within the implementation. We chose the second definition since it can be extended to all positive real numbers of Quick workaround until it is fixed: subtract Unfortunately since |
I'd like to point out that the quick work-around doesn't seem to work. In the example given by dsyme if I run this on my PC I get positive integer and 0 samples. I don't follow how this can be interpreted as "the number of trials (for reaching r successes)". Knocking off 2.0 from a 0 sample, regardless of types, doesn't seem to make sense. Can someone elaborate? |
I might have pinpointed the problem in NegativeBinomial, the code is:
The first code line should be replaced by
Also, it would be nice to point-out in the code that the second part is actually drawing a Poisson sample (which could benefit from the optimized implementation in |
Is there a plan to implement the fix suggested by @vermorel above? This would solve a similar issue I'm seeing. EDIT: Correction - having given further thought it should be p/(1-p) not (1-p)/p |
The sample method is simply incorrect, @tlatarche's proposal is correct. |
Playing around with distributions and it seems that the Mean of the NegativeBinomial distribution doesn't match the mean of samples.
The text was updated successfully, but these errors were encountered: