public CodonFitnessFunction(int codonCount,double alpha,double beta,double pInv){
  GammaDistribution gamma=new GammaDistribution(beta,alpha);
  stateSize=20;
  fitness=new double[codonCount][stateSize];
  byte[] aaFittest=new byte[codonCount];
  fittest=getFittestGenome(codonCount,aaFittest);
  for (int i=0; i < codonCount; i++) {
    fitness[i][aaFittest[i]]=1.0;
    for (int j=0; j < stateSize; j++) {
      if (j != aaFittest[i]) {
        if (MathUtils.nextDouble() < pInv) {
          fitness[i][j]=0.0;
        }
 else {
          double prob=Math.round(MathUtils.nextDouble() * 1000.0) / 1000.0;
          while ((prob <= 0.0) || (prob >= 1.0)) {
            prob=Math.round(MathUtils.nextDouble() * 1000.0) / 1000.0;
          }
          fitness[i][j]=Math.max(0.0,1.0 - gamma.quantile(prob));
        }
      }
    }
  }
}

public CodonFitnessFunction ( int codonCount , double alpha , double beta , double pInv ) { GammaDistribution gamma = new GammaDistribution ( beta , alpha ) ; stateSize = 20 ; fitness = new double [ codonCount ] [ stateSize ] ; byte [ ] aaFittest = new byte [ codonCount ] ; fittest = getFittestGenome ( codonCount , aaFittest ) ; for ( int i = 0 ; i < codonCount ; i ++ ) { fitness [ i ] [ aaFittest [ i ] ] = 1.0 ; for ( int j = 0 ; j < stateSize ; j ++ ) { if ( j != aaFittest [ i ] ) { if ( MathUtils . nextDouble ( ) < pInv ) { fitness [ i ] [ j ] = 0.0 ; } else { double prob = Math . round ( MathUtils . nextDouble ( ) * 1000.0 ) / 1000.0 ; while ( ( prob <= 0.0 ) || ( prob >= 1.0 ) ) { prob = Math . round ( MathUtils . nextDouble ( ) * 1000.0 ) / 1000.0 ; } fitness [ i ] [ j ] = Math . max ( 0.0 , 1.0 - gamma . quantile ( prob ) ) ; } } } } }
selection coefficients are gamma distributed with parameters alpha and beta
