simulate_multinomial
function simulate_multinomial(n:Integer, ρ:Real[_]) -> Integer[_]
Simulate a multinomial distribution.
- n: Number of trials.
- ρ: Category probabilities. These should sum to one.
This uses an \mathcal{O}(N) implementation based on:
Bentley, J. L. and J. B. Saxe (1979). Generating sorted lists of random numbers. Technical Report 2450, Carnegie Mellon University, Computer Science Department.
function simulate_multinomial(n:Integer, ρ:Real[_], Z:Real) -> Integer[_]
Simulate a multinomial distribution.
- n: Number of trials.
- ρ: Unnormalized category probabilities.
- Z: Sum of the unnormalized category probabilities.
This uses an \mathcal{O}(N) implementation based on:
Bentley, J. L. and J. B. Saxe (1979). Generating sorted lists of random numbers. Technical Report 2450, Carnegie Mellon University, Computer Science Department.