Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How Anki calculates intervals

Reading _nextRevIvl and its subfunction _constrainedIvl plus _rescheduleLapse will illuminate how Anki calculates the due date (the “interval”) of a flashcard, based on whether you answer

  • 1 (fail)
  • 2 (pass but hard)
  • 3 (pass)
  • 4 (pass and easy)

This is more of a self-note, so I assume you’ve read the Anki manual top-to-bottom a couple of times.

Let d >= 0, “delay”, be the days between the due date and the date you actually reviewed. This can be important because if you successfully answer a flashcard a long time after it was due for study, that means you probably know it really well.

Let f, “factor” be the flashcard’s factor, which is Anki’s estimate for how well you’ve memorized this flashcard. The bigger the number, the better you understand it. It’s maximum is 1300 and it gets incremented by 150 to 200 “points” every review, as we will show below.

A few user-configured parameters. Let m be the “interval modifier”, a number nominally around 1.0 but that a user can set higher or lower. Anki multiplies the interval by this number, letting the user ask for more or less time between reviews uniformly, across all cards. Let m4 be another user-specified interval modifier, by default 1.3, which applies for “easy” reviews (hence the “4” in the name). And let m0 be the user-specified “new interval”, i.e., a small number closer to 0 than 1 that’s used when you fail a card. By default m0 = 0.

Finally, let i be the most-recent interval.

Here’s how to calculate the new interval:

  • i1 = m0 * i is the new interval for failed reviews. It can have a minimum.
  • i2 = max(i + 1, (i + d/4) * 1.2 * m) is the new interval for hard reviews.
  • i3 = max(i2 + 1, (i + d/2) * (f / 1000) * m) is the new interval for ok reviews.
  • i4 = max(i3 + 1, (i + d) * (f / 1000) * m * m4) is the new interval for easy reviews.

And here’s another very important piece: how to calculate the new factor f. Recall that this is Anki’s guess of the strengh of the memory in your mind, and it controls the exponential growth of intervals for ok (#3) and easy (#4) reivews.

  • f' = f - 200 when you fail a review (#1, reference)
  • f' = f - 150 for a hard review (#2).
  • f' = f for an ok review (#3). No change in factor.
  • f' = max(1300, f + 150) for an easy review (#4, reference).

In words, failed and hard reviews decrease the rate of exponential growth of intervals. Ok reivews maintain it. Easy reviews increase the rate of growth.

So the "factor" is what is actually called "easiness" in the manual and the settings?
Are you sure it's f/1000? That would reduce the interval. Since the easiness is given in % and you're using just a regular number as f, it would make sense to divide it by 100 - that's basically translating the number in % into a normal one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment