static private String calcThreshold(double scoreThreshold,double lambda){
  final double logProbThreshold=Math.log(1 - scoreThreshold / 0.999);
  int maxNum=1000000;
  if (calcLogProb(maxNum,false,lambda) > logProbThreshold) {
    return ">1e6";
  }
  int minNum=1;
  while (minNum < maxNum) {
    final int midNum=(maxNum + minNum) / 2;
    final boolean passThreshold=calcLogProb(midNum,false,lambda) <= logProbThreshold;
    if (passThreshold) {
      maxNum=midNum;
    }
 else {
      if (midNum == minNum) {
        break;
      }
      minNum=midNum;
    }
  }
  return Integer.toString(maxNum);
}

static private String calcThreshold ( double scoreThreshold , double lambda ) { final double logProbThreshold = Math . log ( 1 - scoreThreshold / 0.999 ) ; int maxNum = 1000000 ; if ( calcLogProb ( maxNum , false , lambda ) > logProbThreshold ) { return ">1e6" ; } int minNum = 1 ; while ( minNum < maxNum ) { final int midNum = ( maxNum + minNum ) / 2 ; final boolean passThreshold = calcLogProb ( midNum , false , lambda ) <= logProbThreshold ; if ( passThreshold ) { maxNum = midNum ; } else { if ( midNum == minNum ) { break ; } minNum = midNum ; } } return Integer . toString ( maxNum ) ; }
calculate the mininal number of instances required to achieve a score as high as the given scorethreshold for the given lambda
