A client has asked me to add a simple spaced repeition algorithm (SRS) for an onlinebased learning site. But before throwing my self into it, I\'d like to discuss it with the co
What you want to do is to have a number X_i
for all questions i
. You can normalize these numbers (make their sum 1) and pick one at random with the corresponding probability.
If N
is the number of different questions and M
is the number of times each question has been answered in average, then you could find X
in M*N
time like this:
X[N]
set to 0.i
answered wrong, increase N[i]
by f(t)
where t
is the answering time and f
is an increasing function.Because f
is increasing, a question answered wrong a long time ago has less impact than one answered wrong yesterday. You can experiment with different f
to get a nice behaviour.
The smarter way
A faster way is not to generate X[]
every time you choose questions, but save it in a database table.
You won't be able to apply f
with this solution. Instead just add 1 every time the question is answered wrongly, and then run through the table regularly - say every midnight - and multiply all X[i]
by a constant - say 0.9
.
Update: Actually you should base your data on corrects, not wrongs. Otherwise, questions not answered neither true nor false for a long time, will have a smaller chance of getting chosen. It should be opposite.