private boolean checkConvergence(double oldLikelihood, double newLikelihood, int currentIteration, int maxIterations, double tolerance) {
        return ((tolerance > 0.0d && (Math.abs(oldLikelihood - newLikelihood) <= tolerance || (maxIterations > 0 && currentIteration >= maxIterations))) || (tolerance <= 0.0d && currentIteration == maxIterations) || Double.isNaN(newLikelihood) || Double.isInfinite(newLikelihood));// Stopping criteria is likelihood convergence or number of iterations
    }