title: Sample multinomial distribution in Matlab without using mnrnd
body: <p>I know for a random variable x that P(x=i) for each i=1,2,...,100. Then how may I sample x by a multinomial distribution, based on the given P(x=i) in Matlab?</p>
  
  <p>I am allowed to use the Matlab built-in commands <code>rand</code> and <code>randi</code>, but not <code>mnrnd</code>.</p>