Skip to content

Commit

Permalink
Fix/calculate current retrievability with FSRS-4.5 (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock authored May 16, 2024
1 parent f438477 commit 2c8c951
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fsrs"
version = "0.6.3"
version = "0.6.4"
authors = ["Open Spaced Repetition"]
categories = ["algorithms", "science"]
edition = "2021"
Expand Down
15 changes: 14 additions & 1 deletion src/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ impl<B: Backend> FSRS<B> {
/// How well the user is likely to remember the item after `days_elapsed` since the previous
/// review.
pub fn current_retrievability(&self, state: MemoryState, days_elapsed: u32) -> f32 {
(days_elapsed as f32 / (state.stability * 9.0) + 1.0).powi(-1)
(days_elapsed as f64 / state.stability as f64 * FACTOR + 1.0).powf(DECAY) as f32
}

/// Returns the universal metrics for the existing and provided parameters. If the first value
Expand Down Expand Up @@ -571,6 +571,19 @@ mod tests {
Ok(())
}

#[test]
fn current_retrievability() {
let fsrs = FSRS::new(None).unwrap();
let state = MemoryState {
stability: 1.0,
difficulty: 5.0,
};
assert_eq!(fsrs.current_retrievability(state, 0), 1.0);
assert_eq!(fsrs.current_retrievability(state, 1), 0.9);
assert_eq!(fsrs.current_retrievability(state, 2), 0.82502866);
assert_eq!(fsrs.current_retrievability(state, 3), 0.76613088);
}

#[test]
fn memory_from_sm2() -> Result<()> {
let fsrs = FSRS::new(Some(&[]))?;
Expand Down

0 comments on commit 2c8c951

Please sign in to comment.