code: private double[][] estimateGamma(double[][][] xi) {
          double[][] gamma = new double[xi.length + 1][numStates];
  
          for (int t = 0; t < xi.length; t++) {
              for (int i = 0; i < numStates; i++) {
                  for (int j = 0; j < numStates; j++) {
                      gamma[t][i] += xi[t][i][j];
                  }
              }
          }
  
          int n = xi.length - 1;
          for (int j = 0; j < numStates; j++) {
              for (int i = 0; i < numStates; i++) {
                  gamma[xi.length][j] += xi[n][i][j];
              }
          }
  
          return gamma;
      }
docs: gamma[][] could be computed directly using the alpha and beta arrays, but
  this (slower) method is preferred because it doesn't change if the xi
  array has been scaled (and should be changed with the scaled alpha and
  beta arrays).