public static final double expectation(double ruleCount, int premiseCount,double[] midPoints, Hashtable priors){

    double numerator = 0, denominator = 0;
    for(int i = 0;i < midPoints.length; i++){
      Double actualPrior = (Double)priors.get(new Double(midPoints[i]));
      if(actualPrior != null){
	if(actualPrior.doubleValue() != 0){
	  double addend = actualPrior.doubleValue() * binomialDistribution(midPoints[i], ruleCount, (double)premiseCount);
	  denominator += addend;
	  numerator += addend*midPoints[i];
	}
      }
    }
    if(denominator <= 0 || Double.isNaN(denominator))
      System.out.println("RuleItem denominator: "+denominator);
    if(numerator <= 0 || Double.isNaN(numerator))
      System.out.println("RuleItem numerator: "+numerator);
    return numerator/denominator;
  }