Skip to content

Wrong implementation of the SM2 algorithm #1

@brumar

Description

@brumar

First of all, thank you a lot for this library coded with high quality standards. It saved me a lot of time. Here is my contribution :

I just noticed that your interval computation does not strictly follow the SM2 algorithm

    public function calcInterval($time = 1, $factor = 2.5)
    {
//some lines dropped
            $interval = self::calcInterval($time - 1, $factor) * $factor;
        }
//some lines dropped
    }

I think you had a strict interpretation of this line :_''' I(n):=I(n-1)_EF'''* , that's why you got into a recursive computation to find I(n). Indeed, this mathematical notation seems dubious to me and should have been rewritten as '''I(n):=I(n-1)*EF(n)''' to be less ambiguous. If you are skeptic about my comment, you can check the implementation this function in anki .

def _nextInterval(self, card, delay, ease):

Your computation of the new interval can be problematic for cards with a lot of repetitions small changes on EF involves big changes on the interval (it can suddenly double or divided by two for cards with more than 5 repetitions).

Diving more into SM2 for the purpose of this comment, I also realised that another misunderstanding might have occurred.

    public function calcNewFactor($oldFactor = 2.5, $quality = 4)
    {
//some lines dropped
newFactor = $oldFactor+(0.1-(5-$quality)*(0.08+(5-$quality)*0.02));       
return $newFactor > 1.3 ? ($newFactor < 2.5 ? $newFactor : 2.5) : 1.3;
    }

Avoiding $newFactor > 2.5 seems not consistent with the SM2 algorithm. I think you got mislead (and once again, the original article is not really clear) because the statement "E-Factors were allowed to vary between 1.1 for the most difficult items and 2.5 for the easiest ones" seems to be only related to the SM-0 (or SM-1 ?) algorithm. I also checked on anki, and there is no track of this upper bound.
Best Regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions