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

add truncated negative binomial #25

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

mfansler
Copy link

This adds a truncated negative binomial distribution, including support for both prob and mu parameterizations. Tests are included, covering a similar regimen as truncated Poisson.

Description is updated to minor bump the version, include the new distribution, and add authorship.

Comment on lines +158 to +161
double u, pa, pb;
pa = R::pnbinom(a, size, prob, true, false);
pb = R::pnbinom(b, size, prob, true, false);

Copy link
Owner

Choose a reason for hiding this comment

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

This part repeats in all methods, so probably could be extracted as a separate method.

Copy link
Author

Choose a reason for hiding this comment

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

@twolodzko Please elaborate. Are you suggesting something like below?

double u, pa, pb;
tie(pa, pb) = pnbinom_ends(a, b, size, prob);

We'd need a second pnbinom_ends_mu. Maybe you can propose a better name.

Copy link
Owner

Choose a reason for hiding this comment

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

I mean that calling R::pnbinom_mu and R::pnbinom with the same parameters happens several times in the code so they can be extracted as separate functions.

@twolodzko
Copy link
Owner

Could you rebase with master? I made some minor fixes.

@twolodzko
Copy link
Owner

Besides the refactor, I don't have other comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants