Hi,
I've been taking a look at mnemosyne and the sm2 algorithm, and am
interested in learning a bit more, specifically whether I've correctly
interpreted the descriptions of the spacing algorithm.
I've read through a number of posts/threads to this group regarding
the algorithm and implementation,
http://groups.google.com/group/mnemosyne-proj-users/browse_thread/thread/9777f22da2a6c200/0b2171caf1fda9b4?lnk=gst&q=algorithm#0b2171caf1fda9b4
http://groups.google.com/group/mnemosyne-proj-users/browse_thread/thread/f3843472c8f06b7a/a9ae1059bc642cb0?lnk=gst&q=algorithm#a9ae1059bc642cb0
http://groups.google.com/group/mnemosyne-proj-users/browse_thread/thread/ab571900156a7e0e/b4a76e789c7d95db?lnk=gst&q=algorithm#b4a76e789c7d95db
as well as the original sm1 and sm2 descriptions,
http://www.supermemo.com/english/ol/beginning.htm
http://www.supermemo.com/english/ol/sm2.htm
Based on the list postings, etc. it seems there is some interest in
a simplified implementation of the spacing algorithm, so I've written
a short python script to calculate intervals based on the important
variables mentioned in the above descriptions, namely
n = n-th repetition
q = user-supplied 'quality of response'
EF = E-factor
If I've understood the description correctly, the script below
should account for steps 1-6 in the sm2 algorithm, leaving only the
scheduling, and possibly randomization of otherwise equivalent items.
(seems I can't preview my post so sorry in advance if the code below
gets mangled...)
#!/usr/bin/python
def getInterval( n, ef=2.5 ):
"""
Calculate the inter-repetition interval
based on,
n = n-th (current) repetition
ef = easiness-factor (1~5)
"""
if n < 1:
raise ValueError, 'n must be greater than 0!'
if n==1:
return 1.0
elif n==2:
return 6.0
else:
return float(int(getInterval( n-1, ef=ef )*ef))
def getEasinessFactor( n, oldEF=2.5, q=4.0 ):
"""
Calculate a new easiness-factor,
EF' := f(EF,q)
where,
EF' = new value of the E-factor
EF = old value of the E-factor
q = user-reported quality of response (0~5)
f(EF,q) = EF-0.8+0.28*q-0.02*q*q
note that, for q=4.0 the E-factor does not change
Details at,
http://www.supermemo.com/english/ol/sm2.htm
"""
if n < 1:
raise ValueError, 'n must be greater than 0!'
if q==1 : return 1, oldEF
if q==2 : return 2, oldEF
newEF = oldEF - 0.8 + 0.28 * q - 0.02 * q * q
if newEF < 1.3:
newEF=1.3
return n, newEF
if __name__=="__main__":
import sys
print "First 10 intervals (constant default EF=2.5):"
for n in xrange( 1, 11 ):
print " %.1f" % getInterval( n )
n, q = int(sys.argv[1]), float(sys.argv[2])
if len(sys.argv)==4:
n, newEF = getEasinessFactor( n, oldEF=float(sys.argv[3]),
q=q )
else:
n, newEF = getEasinessFactor( n, q=q )
print "\nInterval for n=%d, q=%.1f, ef=%.1f" % (n, q, newEF)
print " %.1f" % getInterval( n, ef=newEF )
I'd like to know if I've understood the descriptions correctly, and if
not, what I've gotten wrong. Also, it seemed to me that steps 5, and
6 on the sm2 description page are in the wrong order, which has me
worried that I've misunderstood something,
5. After each repetition modify the E-Factor of the recently
repeated item according to the formula...
6. If the quality response was lower than 3 then start repetitions
for the item from the beginning without changing the E-Factor...
In any implementation, my understanding of the above implies that 6.
should always be tested before 5, correct?
Cheers,
Joe