Skip to content

Commit

Permalink
stop using math.exp and math.pow
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdavham committed Jan 7, 2025
1 parent 70a8d4c commit afa2bdb
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions fsrs/fsrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ def _initial_stability(self, rating: Rating) -> float:

def _initial_difficulty(self, rating: Rating) -> float:
initial_difficulty = (
self.parameters[4] - math.exp(self.parameters[5] * (rating - 1)) + 1
self.parameters[4] - (math.e ** (self.parameters[5] * (rating - 1))) + 1
)

# bound initial_difficulty between 1 and 10
Expand All @@ -683,8 +683,8 @@ def _next_interval(self, stability: float) -> int:
return next_interval

def _short_term_stability(self, stability: float, rating: Rating) -> float:
return stability * math.exp(
self.parameters[17] * (rating - 3 + self.parameters[18])
return stability * (
math.e ** (self.parameters[17] * (rating - 3 + self.parameters[18]))
)

def _next_difficulty(self, difficulty: float, rating: Rating) -> float:
Expand Down Expand Up @@ -733,13 +733,13 @@ def _next_forget_stability(
) -> float:
next_forget_stability_long_term_params = (
self.parameters[11]
* math.pow(difficulty, -self.parameters[12])
* (math.pow(stability + 1, self.parameters[13]) - 1)
* math.exp((1 - retrievability) * self.parameters[14])
* (difficulty ** -self.parameters[12])
* (((stability + 1) ** (self.parameters[13])) - 1)
* (math.e ** ((1 - retrievability) * self.parameters[14]))
)

next_forget_stability_short_term_params = stability / math.exp(
self.parameters[17] * self.parameters[18]
next_forget_stability_short_term_params = stability / (
math.e ** (self.parameters[17] * self.parameters[18])
)

return min(
Expand All @@ -755,10 +755,10 @@ def _next_recall_stability(

return stability * (
1
+ math.exp(self.parameters[8])
+ (math.e ** (self.parameters[8]))
* (11 - difficulty)
* math.pow(stability, -self.parameters[9])
* (math.exp((1 - retrievability) * self.parameters[10]) - 1)
* (stability ** -self.parameters[9])
* ((math.e ** ((1 - retrievability) * self.parameters[10])) - 1)
* hard_penalty
* easy_bonus
)
Expand Down

0 comments on commit afa2bdb

Please sign in to comment.