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

Second attempt at C++ implementation of Ebola model #179

Closed
pratikunterwegs opened this issue Feb 16, 2024 · 1 comment
Closed

Second attempt at C++ implementation of Ebola model #179

pratikunterwegs opened this issue Feb 16, 2024 · 1 comment
Assignees
Labels
C++ Related to C++ code Discussion Issues kept open for discussions in the comments Stochastic models

Comments

@pratikunterwegs
Copy link
Member

This issue requests a second attempt at an implementation of the ebola model. The previous Rcpp implementation was removed in #140, as it did not offer a substantial speed gain.

Possible reasons for no speed gain, and possible targets for improvement:

  • prob_discrete_erlang() could be made more efficient;
  • use of stats::multinomial() for a single draw could be replaced with a function wrapping sample() or with a custom weighted lottery function; see e.g. this implemenation in {pathomove};
  • use of more efficient book-keeping;
  • use of more C++ standard library structures instead of Rcpp vectors (?);
  • simplifying the implementation to reduce random number draws (perhaps at the expense of more if-else?)

Note: make sure to use Rcpp-provided random number draws, or to include a wrapper to the R random number generator to take advantage of seed management through R.

@pratikunterwegs pratikunterwegs added C++ Related to C++ code Discussion Issues kept open for discussions in the comments Stochastic models labels Feb 16, 2024
@pratikunterwegs pratikunterwegs self-assigned this Feb 16, 2024
@pratikunterwegs
Copy link
Member Author

This issue is a candidate for closing: the implementation of stats::rmultinom() is a very efficient way of drawing from a weighted categorical distribution, written in C; it cannot easily be improved by re-writing in Rcpp. This has been added to the design principles vignette.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ Related to C++ code Discussion Issues kept open for discussions in the comments Stochastic models
Development

No branches or pull requests

1 participant