inline bool GetPosterior ( const std::vector< int > matches, std::vector< float > p_quals, int n ) 
	{
		std::pair <double,double> ls = GetLikelihood ( matches, p_quals, n );
//		double p_denom = quality_score_trait_.prior_*ls_con_ + (1-quality_score_trait_.prior_)*ls_ran_;	//same result should holds with/without p_denom dividing operation
		double ps_con = (ls.first * quality_score_trait_.prior_);// /p_denom; 
		double ps_ran = (ls.second * (1-quality_score_trait_.prior_)); // /p_denom;
		return ps_con > ps_ran;
	}
Borders MakeOptimalBorders(const Matrix &probabilities) {
  Matrix logProbabilities = probabilities;
  Log(&logProbabilities);

  Matrix partialSums;
  ComputePartialSums(logProbabilities, &partialSums);


  Borders borders = MakeInitialBorders(logProbabilities.front().size() - 1,
                                       logProbabilities.size() - 1);
  Borders optimalBorders;
  double maximumLikelihood = GetLikelihood(partialSums, borders);

  while (MakeNextBorders(&borders) > 0) {
    double likelihood = GetLikelihood(partialSums, borders);
    if (likelihood > maximumLikelihood) {
      maximumLikelihood = likelihood;
      optimalBorders = borders;
    }
  }
  return optimalBorders;
}