0

I would like to generate random numbers from a Multinomial distribution. Say you have n and p_1,...p_m such that sum of p_1, ...,p_m is equal to 1. I know n and p_1,...,p_m values. Ideally, I would like to write a code in Python; but a general algorithm would definitely suffice. Obviously, output of my code would be m random numbers x_1,...,x_m such that sum of x_1,..., x_m is n.

NNsr
  • 1,023
  • 2
  • 11
  • 25
  • 2
    Use `numpy`: [`numpy.random.multinomial`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.multinomial.html) – Blender Jun 24 '13 at 19:00
  • @Blender: Thank you for your comment. Is there anyway that I can get the algorithm for generating these numbers? – NNsr Jun 24 '13 at 19:02
  • 1
    See [To simulate a multinomial distribution](http://en.wikipedia.org/wiki/Multinomial_distribution#To_simulate_a_multinomial_distribution). – martineau Jun 24 '13 at 20:49

0 Answers0