This is C++ program to implement the SAS method.
To use the SAS method, just include the sas in your C++ source code. Some tests have been taken in test.cpp file.
References:
-
Ilari Vallivaara, Katja Poikselkä, Pauli Rikula, and Juha Röning. 2016. Systematic Alias Sampling: An Efficient and Low-Variance Way to Sample from a Discrete Distribution. ACM Trans. Math. Softw. 43, 3, Article 18 (August 2016), 17 pages. DOI: https://doi.org/10.1145/2935745
-
Kronmal, Richard A., and Arthur V. Peterson. “On the Alias Method for Generating Random Variables from a Discrete Distribution.” The American Statistician, vol. 33, no. 4, 1979, pp. 214–218. www.jstor.org/stable/2683739.