New Distribution: dynamic_discrete_distribution#155
Open
bookworm6 wants to merge 1 commit into
Open
Conversation
dynamic_discrete_distribution is a dynamic_distribution with updatable weights. Selection and update have been highly optimized
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
dynamic_discrete_distribution is a dynamic_distribution with updatable weights. Selection and update have been highly optimized.
Motivation
Though it has many possible applications, this implementation is designed for discrete event simulation applications. In these applications, there is a set of events with different probabilities of occurring, and the simulation must choose an event to occur and update probabilities of other events accordingly. These simulations often involve many more updates than selections, but exact ratios of update to selection differ depending on the application. This implementation provides efficient update and selection in which the underlying tree data structure can be tuned at compile time to prioritize update over selection to varying degrees.
Asymptotic Runtime of Update and Selection
In this library, we introduce a template parameter
Fanoutwhich controls the branching factor of the underlying complete tree data structure and can be adjusted to change the amount that update is prioritized over selection. It must be a positive integer power of 2 (enforced with a static assert at compile time). Our runtime is analyzed in terms of N (the number of elements in the distribution) and Fanout.Justification for asymptotically logarithmic update and selection
We compared our implementation of dynamic weighted random selection against the asymptotically more efficient versions BUS and DPA.