protected int chooseRandomIndexBasedOnProportions(double[] proportionArray,Random random){
  double probSum;
  double val;
  int index;
  double sum;
  probSum=Utils.sum(proportionArray);
  val=random.nextDouble() * probSum;
  index=0;
  sum=0.0;
  while ((sum <= val) && (index < proportionArray.length)) {
    sum+=proportionArray[index++];
  }
  return index - 1;
}

protected int chooseRandomIndexBasedOnProportions ( double [ ] proportionArray , Random random ) { double probSum ; double val ; int index ; double sum ; probSum = Utils . sum ( proportionArray ) ; val = random . nextDouble ( ) * probSum ; index = 0 ; sum = 0.0 ; while ( ( sum <= val ) && ( index < proportionArray . length ) ) { sum += proportionArray [ index ++ ] ; } return index - 1 ; }
returns a random index based on the given proportions
