Skip to content
This repository was archived by the owner on Jan 19, 2026. It is now read-only.

add truncated negative binomial#25

Open
mfansler wants to merge 6 commits into
twolodzko:masterfrom
mfansler:tnbinom
Open

add truncated negative binomial#25
mfansler wants to merge 6 commits into
twolodzko:masterfrom
mfansler:tnbinom

Conversation

@mfansler
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Owner

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

@twolodzko
Copy link
Copy Markdown
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants