@Override
  public final void compute() {

    String testType;
    if (tail.getTextString().equals("<")) {
      testType = "left";
    } else if (tail.getTextString().equals(">")) {
      testType = "right";
    } else if (StringUtil.isNotEqual(tail.getTextString())) {
      testType = "two";
    } else {
      result.setUndefined();
      return;
    }

    double n1 = n.getDouble();
    double phat1 = proportion.getDouble();
    double n2 = n_2.getDouble();
    double phat2 = proportion2.getDouble();

    double x1 = phat1 * n1;
    double x2 = phat2 * n2;
    double phatTotal = (x1 + x2) / (n1 + n2);
    se = Math.sqrt(phatTotal * (1 - phatTotal) * (1 / n1 + 1 / n2));
    double testStatistic = (phat1 - phat2) / se;

    NormalDistributionImpl normalDist = new NormalDistributionImpl(0, 1);
    double P = 0;
    try {
      P = normalDist.cumulativeProbability(testStatistic);
    } catch (Exception e) {
      result.setUndefined();
      return;
    }

    if ("right".equals(testType)) {
      P = 1 - P;
    } else if ("two".equals(testType)) {
      if (testStatistic < 0) {
        P = 2 * P;
      } else {
        P = 2 * (1 - P);
      }
    }

    // put these results into the output list
    result.clear();
    result.addNumber(P, null);
    result.addNumber(testStatistic, null);
  }
  private void calculateZValues(int n) {

    zValues = new double[n];
    NormalDistributionImpl normalDist = new NormalDistributionImpl(0, 1);
    double x;

    try {
      x = 1 - Math.pow(0.5, 1.0 / n);
      zValues[0] = normalDist.inverseCumulativeProbability(x);

      for (int i = 2; i < n; i++) {
        x = (i - 0.3175) / (n + 0.365);
        zValues[i - 1] = normalDist.inverseCumulativeProbability(x);
      }

      x = Math.pow(0.5, 1.0 / n);
      zValues[n - 1] = normalDist.inverseCumulativeProbability(x);

    } catch (MathException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }