title: Prize distribution algorithm to handle ties
body: <p>I'm trying to come up with a prize distribution algorithm that can scalably handle different number of players and factor in ties i.e in case the contestants fall in the same position.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>Distribution Formula        
  P=((1-d)/1-d^n)*d^(p-1))*A      
  
  Where:      
  P   Prize   
  n   Number of winners   
  A   Total amout of money to share   
  d   Distribution constant &gt;0&lt;1  
  p   Position or rank of the user
  </code></pre>
  
  <p>Modeling it in Excel I get the following results:</p>
  
  <pre><code>Constants
  
  A   50000
  d   0.4
  n   15
  </code></pre>
  
  <p><strong>Sample data</strong></p>
  
  <p><strong>Distribution without ties</strong></p>
  
  <pre><code>Position (p)    Player  Prize (P)
  1   A   30000.03221
  2   B   12000.01288
  3   C   4800.005154
  4   D   1920.002062
  5   E   768.0008246
  6   F   307.2003299
  7   C   122.8801319
  8   D   49.15205278
  9   E   19.66082111
  10  F   7.864328444
  11  C   3.145731378
  12  D   1.258292551
  13  E   0.5033170204
  14  F   0.2013268082
  15  C   0.08053072327
  **Total     50000**
  </code></pre>
  
  <p><strong>Distribution with ties</strong></p>
  
  <pre><code>Position (p)    Player  Prize (P)
  1   A   30000.03221
  1   B   30000.03221
  2   C   12000.01288
  3   D   4800.005154
  4   E   1920.002062
  4   F   1920.002062
  5   C   768.0008246
  6   D   307.2003299
  7   E   122.8801319
  8   F   49.15205278
  9   C   19.66082111
  10  D   7.864328444
  11  E   3.145731378
  12  F   1.258292551
  13  C   0.5033170204
  **Total 81919.75242**   
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>Not my second data with ties the total distributed prizes is more than 50000 which is what I wanted to share</p>
  
  <p><strong>Desired results</strong></p>
  
  <p>Users falling in the same position should get an equal amount and have the prizes well distributed to the other users. The total amount paid out should not be more than what was intended.</p>
  
  <p>How can I improve the above function to achieve the above results.</p>