haskell-fsrs
Safe HaskellSafe-Inferred
LanguageHaskell2010

FSRS.Parameters

Description

The 35 weights of FSRS-7, and typed views onto the blocks they form.

FSRS-7 groups its weights like this:

w0..w3initial stability, indexed by rating
w4..w6difficulty
w7..w15stability update, long-term block
w16..w24stability update, short-term (same-day) block

| w25,w26 | the long-/short-term transition function | +-----------+------------------------------------------------------------+ | w27..w34| the two-component forgetting curve | +-----------+------------------------------------------------------------+

The two stability blocks have identical shapes, which is why longTermWeights and shortTermWeights both produce a StabilityWeights.

Synopsis

Parameters

data Parameters Source #

An FSRS-7 parameter vector: exactly parameterCount weights.

Build one with mkParameters or clampParameters; the constructor is hidden so that the length invariant cannot be broken.

parameterCount :: Int Source #

35. FSRS-6 had 21 weights; FSRS-7 adds a second stability block, the transition function and the six extra forgetting-curve weights.

defaultParameters :: Parameters Source #

The default FSRS-7 parameters, obtained by the upstream authors through multi-user optimisation.

These match models/fsrs_v7.py in srs-benchmark. Note that the Default Parameters section of that repository's README still lists 1.15 for w15 and w24; that block of the README has not been updated since 2026-03-18, while the model was changed to 1.3 three days later. The values below follow the model.

mkParameters :: [Double] -> Either [ParameterError] Parameters Source #

Build a parameter vector, rejecting anything out of bounds.

clampParameters :: [Double] -> Either [ParameterError] Parameters Source #

Build a parameter vector by pulling every weight into its valid range, exactly as the upstream optimiser's clipper does: bounds first, in index order, so that the ordering constraints are resolved against already-clamped neighbours. Only a wrong number of weights can still fail.

parametersToList :: Parameters -> [Double] Source #

The weights as a plain list, in index order.

parameterAt :: Parameters -> Int -> Double Source #

The 0-based weight at the given index. Indices outside [0, parameterCount) are a programmer error and raise an exception.

Validation

data ParameterError Source #

Why a list of weights is not a valid parameter vector.

Constructors

WrongParameterCount !Int

Got this many weights instead of parameterCount.

ParameterOutOfBounds !Int !Double !Double !Double

index, value, lower bound, upper bound.

ParameterOutOfOrder !Int !Int !Double !Double

w[i] <= w[j] is required but was violated: i, j, w[i], w[j].

ParameterNotFinite !Int !Double

index, the offending NaN or infinity.

Instances

Instances details
Show ParameterError Source # 
Instance details

Defined in FSRS.Parameters

Eq ParameterError Source # 
Instance details

Defined in FSRS.Parameters

parameterBounds :: [(Double, Double)] Source #

The inclusive (lower, upper) bound of every weight, in index order.

Taken from the parameter clipper the upstream optimiser applies after each gradient step, so any parameter set produced by a real optimiser satisfies them.

validateParameters :: [Double] -> [ParameterError] Source #

Every problem with a candidate weight list, or [] if there is none.

Weight blocks

initialStabilityWeight :: Parameters -> Rating -> Double Source #

w[rating - 1]: the stability a card is born with after its first review.

transitionRate :: Parameters -> Double Source #

w25: how fast a review stops counting as same-day.

transitionAmplitude :: Parameters -> Double Source #

w26: how much of the short-term behaviour applies at zero elapsed time.

data StabilityWeights Source #

One of the two nine-weight blocks that drive the stability update.

Constructors

StabilityWeights 

Fields

longTermWeights :: Parameters -> StabilityWeights Source #

w7..w15: the block used for reviews separated by a real interval.

shortTermWeights :: Parameters -> StabilityWeights Source #

w16..w24: the block used for same-day reviews.

data CurveWeights Source #

w27..w34: the mixture of two power laws that makes up the FSRS-7 forgetting curve.

Constructors

CurveWeights 

Fields

Instances

Instances details
Show CurveWeights Source # 
Instance details

Defined in FSRS.Parameters

Eq CurveWeights Source # 
Instance details

Defined in FSRS.Parameters

curveWeights :: Parameters -> CurveWeights Source #

Read the forgetting-curve block out of a parameter vector.