Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Sampling from the Multinomial Distribution</h2> <p>The way that you are currently distributing the dollars left over after <code>min</code> has been given to each subbudget involves performing a fixed number <code>budget</code> of random "trials", where on each trial you randomly select one of <code>n</code> categories, and you want to know how many times each category is selected. This is modeled by a <a href="http://en.wikipedia.org/wiki/Multinomial_distribution" rel="nofollow">multinomial distribution</a> with the following parameters:</p> <ul> <li>Number of trials (called <code>n</code> on the WP page): <code>budget</code></li> <li>Number of categories (called <code>k</code> on the WP page): <code>n</code></li> <li>Probability of category <code>i</code> in each trial, for <code>1 &lt;= i &lt;= n</code>: <code>1/n</code></li> </ul> <p>The way you are currently doing it is a good way if the number of trials is around the same size as the number of categories, or less. But if the budget is large, there are other more efficient ways of sampling from this distribution. The easiest way I know of is to notice that a multinomial distribution with <code>k</code> categories can be repeatedly decomposed into binomial distributions by grouping categories together: instead of directly how many selections there are for each of the <code>k</code> categories, we express this as a sequence of questions: "How to split the budget between the first category and the other <code>k-1</code>?" We next ask "How to split the remainder between the second category and the other <code>k-2</code>?", etc.</p> <p>So the top level binomial has category (subbudget) 1 vs. everything else. Decide the number of dollars that go to subbudget 1 by taking 1 sample from a binomial distribution with parameters <code>n = budget</code> and <code>p = 1/n</code> (how to do this is described <a href="http://en.wikipedia.org/wiki/Binomial_distribution#Generating_binomial_random_variates" rel="nofollow">here</a>); this will produce some number <code>0 &lt;= x[1] &lt;= n</code>. To find the number of dollars that go to subbudget 2, take 1 sample from a binomial distribution on the remaining money, i.e. using parameters <code>n = budget - x[1]</code> and <code>p = 1/(n-1)</code>. After getting subbudget 2's amount x[2], subbudget 3's will be found using parameters <code>n = budget - x[1] - x[2]</code> and <code>p = 1/(n-2)</code>, and so on.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload