Skip to content

Commit

Permalink
Fix/clip post lapse stability (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishiko732 authored Dec 17, 2024
1 parent f0b1369 commit af8f873
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-fsrs",
"version": "4.5.0",
"version": "4.5.1",
"description": "ts-fsrs is a versatile package based on TypeScript that supports ES modules, CommonJS, and UMD. It implements the Free Spaced Repetition Scheduler (FSRS) algorithm, enabling developers to integrate FSRS into their flashcard applications to enhance the user learning experience.",
"main": "dist/index.cjs",
"umd": "dist/index.umd.js",
Expand Down
2 changes: 2 additions & 0 deletions src/fsrs/algorithm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ export class FSRSAlgorithm {
/**
* The formula used is :
* $$S^\prime_f(D,S,R) = w_{11}\cdot D^{-w_{12}}\cdot ((S+1)^{w_{13}}-1) \cdot e^{w_{14}\cdot(1-R)}$$
* enable_short_term = true : $$S^\prime_f \in \min \lbrace \max \lbrace S^\prime_f,0.01\rbrace, \frac{S}{e^{w_{17} \cdot w_{18}}} \rbrace$$
* enable_short_term = false : $$S^\prime_f \in \min \lbrace \max \lbrace S^\prime_f,0.01\rbrace, S \rbrace$$
* @param {number} d Difficulty D \in [1,10]
* @param {number} s Stability (interval when R=90%)
* @param {number} r Retrievability (probability of recall)
Expand Down
2 changes: 1 addition & 1 deletion src/fsrs/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const default_w = [
export const default_enable_fuzz = false
export const default_enable_short_term = true

export const FSRSVersion: string = 'v4.5.0 using FSRS-5.0'
export const FSRSVersion: string = 'v4.5.1 using FSRS-5.0'

export const generatorParameters = (
props?: Partial<FSRSParameters>
Expand Down
17 changes: 13 additions & 4 deletions src/fsrs/impl/basic_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,20 @@ export default class BasicScheduler extends AbstractScheduler {
difficulty,
Rating.Again
)
next_again.stability = this.algorithm.next_forget_stability(
difficulty,
stability,
retrievability
const nextSMin =
stability /
Math.exp(
this.algorithm.parameters.w[17] * this.algorithm.parameters.w[18]
)
next_again.stability = Math.min(
+nextSMin.toFixed(8),
this.algorithm.next_forget_stability(
difficulty,
stability,
retrievability
)
)

next_hard.difficulty = this.algorithm.next_difficulty(
difficulty,
Rating.Hard
Expand Down
10 changes: 7 additions & 3 deletions src/fsrs/impl/long_term_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,15 @@ export default class LongTermScheduler extends AbstractScheduler {
difficulty,
Rating.Again
)
next_again.stability = this.algorithm.next_forget_stability(
difficulty,
next_again.stability = Math.min(
stability,
retrievability
this.algorithm.next_forget_stability(
difficulty,
stability,
retrievability
)
)

next_hard.difficulty = this.algorithm.next_difficulty(
difficulty,
Rating.Hard
Expand Down

0 comments on commit af8f873

Please sign in to comment.