Skip to content

Commit

Permalink
Feat/fine-tune the sample size for CMRR (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
L-M-Sherlock authored Sep 10, 2024
1 parent 16fe70b commit bc5d602
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 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 = "1.2.1"
version = "1.2.2"
authors = ["Open Spaced Repetition"]
categories = ["algorithms", "science"]
edition = "2021"
Expand Down
17 changes: 12 additions & 5 deletions src/optimal_retention.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,9 +528,16 @@ impl<B: Backend> FSRS<B> {
let tol = 0.01f32;

let sample_size = match config.learn_span {
..100 => 16,
100..365 => 8,
_ => 4,
..=30 => 45,
31..365 => {
let (a1, a2, a3) = (8.20e-7, 2.41e-3, 1.30e-2);
let factor = (config.learn_span as f32)
.powf(2.0)
.mul_add(a1, config.learn_span as f32 * a2 + a3);
let default_sample_size = 4.0;
(default_sample_size / factor).round() as usize
}
365.. => 8,
};

let (xb, fb) = (
Expand Down Expand Up @@ -1118,7 +1125,7 @@ mod tests {
..Default::default()
};
let optimal_retention = fsrs.optimal_retention(&config, &[], |_v| true).unwrap();
assert_eq!(optimal_retention, 0.7921062);
assert_eq!(optimal_retention, 0.80994797);
assert!(fsrs.optimal_retention(&config, &[1.], |_v| true).is_err());
Ok(())
}
Expand All @@ -1138,7 +1145,7 @@ mod tests {
let optimal_retention = fsrs
.optimal_retention(&config, &DEFAULT_PARAMETERS[..17], |_v| true)
.unwrap();
assert_eq!(optimal_retention, 0.8430037);
assert_eq!(optimal_retention, 0.8435673);
Ok(())
}

Expand Down

0 comments on commit bc5d602

Please sign in to comment.