simulate_multinomial

function simulate_multinomial(n:Integer, ρ:Real[_]) -> Integer[_]

Simulate a multinomial distribution.

  • n: Number of trials.
  • ρ: Category probabilities.

This uses an 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.