def predictRecallMode(prior, tnow):
    """Mode of the immediate recall probability.

  Same arguments as `ebisu.predictRecall`, see that docstring for details. A
  returned value of 0 or 1 may indicate divergence.
  """
    alpha, beta, t = prior
    dt = tnow / t
    pr = lambda p: p ** ((alpha - dt) / dt) * (1 - p ** (1 / dt)) ** (beta - 1)
    modeBase = (alpha - dt) / (alpha + beta - dt - 1)
    if modeBase >= 0 and modeBase <= 1:
        mode = modeBase ** dt
        modePr = pr(mode)
        eps = 0.001
        others = [eps, mode - eps if mode > eps else mode / 2, mode + eps if
            mode < 1 - eps else (1 + mode) / 2, 1 - eps]
        otherPr = map(pr, others)
        if max(otherPr) <= modePr:
            return mode
    return 0.5 if dt == 1.0 else 0.0 if dt > 1 else 1.0
