Distribution.hpp
A set of pre-calculated discrete distributions that can quickly generate random values.
A Distribution is a pre-calculated set of probabilities to quickly pick a whole-number result. These should be used when either we need to draw from the same distribution many time (and hence the extra time to pre-calculate it is amortized away) -or- in functions that we want to call with a range of distributions that we may not know ahead of time.
Currently, we have:
Uniform - All values in a range are equally likelty to be picked. Binomial - How many successes with p probability will occur in N attempts? NegativeBinomial - How many attempts to reach N successes, with p probability per attempt?
Developer Notes:
We should setup an offset in the base Distribution class to ignore “impossible” low values.
Note
Status: ALPHA
-
class Distribution
- #include <Distribution.hpp>
Subclassed by Binomial, NegativeBinomial, Uniform
Public Functions
-
inline size_t GetSize() const
-
inline double GetTotalProb() const
-
inline double operator[](size_t id) const
-
inline size_t PickPosition(double in_value)
Pick an item from a distribution using a value between 0.0 and 1.0.
Protected Attributes
-
UnorderedIndexMap weights
-
inline size_t GetSize() const
-
class Uniform : public Distribution
- #include <Distribution.hpp>
-
class Binomial : public Distribution
- #include <Distribution.hpp>
How many successes with p probability and N attempts?
-
class NegativeBinomial : public Distribution
- #include <Distribution.hpp>
How many attempts to reach N successes, assuming p probability per attempt?