private void calculateCategoryRates(){
  double propVariable=1.0;
  int cat=0;
  categoryRates[0]=0.0;
  categoryProportions[0]=modelChoose.getValue(INVAR_INDEX) * (1 / (1 + Math.exp(-logitInvar.getValue(0))));
  propVariable=1.0 - categoryProportions[0];
  cat=1;
  if (modelChoose.getValue(SHAPE_INDEX) == PRESENT) {
    final double a=Math.exp(logShape.getValue(0));
    double mean=0.0;
    final int gammaCatCount=categoryCount - cat;
    for (int i=0; i < gammaCatCount; i++) {
      categoryRates[i + cat]=GammaDistribution.quantile((2.0 * i + 1.0) / (2.0 * gammaCatCount),a,1.0 / a);
      mean+=categoryRates[i + cat];
      categoryProportions[i + cat]=propVariable / gammaCatCount;
    }
    mean=(propVariable * mean) / gammaCatCount;
    for (int i=0; i < gammaCatCount; i++) {
      categoryRates[i + cat]/=mean;
    }
  }
 else {
    final int gammaCatCount=categoryCount - cat;
    for (int i=0; i < gammaCatCount; i++) {
      categoryRates[i + cat]=1.0 / propVariable;
      categoryProportions[i + cat]=propVariable / gammaCatCount;
    }
  }
  ratesKnown=true;
}

private void calculateCategoryRates ( ) { double propVariable = 1.0 ; int cat = 0 ; categoryRates [ 0 ] = 0.0 ; categoryProportions [ 0 ] = modelChoose . getValue ( INVAR_INDEX ) * ( 1 / ( 1 + Math . exp ( - logitInvar . getValue ( 0 ) ) ) ) ; propVariable = 1.0 - categoryProportions [ 0 ] ; cat = 1 ; if ( modelChoose . getValue ( SHAPE_INDEX ) == PRESENT ) { final double a = Math . exp ( logShape . getValue ( 0 ) ) ; double mean = 0.0 ; final int gammaCatCount = categoryCount - cat ; for ( int i = 0 ; i < gammaCatCount ; i ++ ) { categoryRates [ i + cat ] = GammaDistribution . quantile ( ( 2.0 * i + 1.0 ) / ( 2.0 * gammaCatCount ) , a , 1.0 / a ) ; mean += categoryRates [ i + cat ] ; categoryProportions [ i + cat ] = propVariable / gammaCatCount ; } mean = ( propVariable * mean ) / gammaCatCount ; for ( int i = 0 ; i < gammaCatCount ; i ++ ) { categoryRates [ i + cat ] /= mean ; } } else { final int gammaCatCount = categoryCount - cat ; for ( int i = 0 ; i < gammaCatCount ; i ++ ) { categoryRates [ i + cat ] = 1.0 / propVariable ; categoryProportions [ i + cat ] = propVariable / gammaCatCount ; } } ratesKnown = true ; }
discretization of gamma distribution with equal proportions in each category
