code: private void findParameters(int iterations) {
      double prevLL = 0.0;
      double currLL = 0.0;
      display("Performing " + iterations + " iterations.\n");
      for (int i = 1; i <= iterations; i++) {
        if (i < 10)
          display("  " + i + ":  ");
        else if (i < 100)
          display(" " + i + ":  ");
        else
          display(i + ":  ");
        currLL = nextIteration();
        if (i > 1) {
          if (prevLL > currLL) {
            System.err.println("Model Diverging: loglikelihood decreased");
            break;
          }
          if (currLL - prevLL < LLThreshold) {
            break;
          }
        }
        prevLL = currLL;
      }
  
      // kill a bunch of these big objects now that we don't need them
      observedExpects = null;
      modelExpects = null;
      numTimesEventsSeen = null;
      contexts = null;
    }
docs: /* Estimate and return the model parameters.