Ascending probabilities with descending numbers
<p>I would like to write code which gives cumulative probabilities (0-1) to each number which are descending in order. For example;</p>

<p>I have a set of number:</p>

<pre><code>    150
    152
    155
    160
    175
</code></pre>

<p>I will give those numbers a probability in this way: </p>

<p>for first one (150) probability is = 175/total Sum    </p>

<p>Second one is = 160/totalsum + previous probability....and so on. </p>

<p>The main point is 150 will have the higher probability than others.</p>

<p>What would you suggest to me. Set will contain more than 30 numbers...</p>

<p>Here is the code:</p>

<pre><code>int ll;
float prefitness=0;//Previous fittnesses
int minus =0;
for (int sdf=0;sdf&lt;PopulationSize;sdf++)//population size is the total number counts
{
  ll=sortindex[sdf];//sortindex is an array with numbers in ascending order
  Sol_list[ll].fittness=(double)Sol_list[PopulationSize-1-minus].PortfolioDuration/sum+prefitness;
  prefitness=Sol_list[ll].fittness;
  minus++;
}
float move=0;
int xc;
for (int yj=0;yj&lt;PopulationSize;yj++)
{
  xc=sortindex[yj];
  Sol_list[xc].fittnesspre =move;
  move=Sol_list[xc].fittness;
}
</code></pre>
