haskell-fsrs
Safe HaskellSafe-Inferred
LanguageHaskell2010

FSRS.Parameters

Description

The 34 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..w14stability update, slow trace
w15..w22stability update, fast trace
w23..w30the two-component forgetting curve
w31..w33how difficulty and stability modulate that curve

The two stability blocks have identical shapes, which is why slowTraceWeights and fastTraceWeights 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 #

34. FSRS-6 had 21 weights. FSRS-7 keeps two stability blocks of eight weights each — one per memory trace — and spends eleven on a forgetting curve that mixes the two traces and is modulated by difficulty.

defaultParameters :: Parameters Source #

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

These are the DEFAULT_PARAMETERS of the finished FSRS-7 reference implementation, https://github.com/Expertium/fsrs-rs-speed-autoresearch.

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: every weight is clamped to its own bounds first, and only then are the ordering constraints restored by raising the larger index. 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.

orderingConstraints :: [(Int, Int)] Source #

Pairs (i, j) for which w[i] <= w[j] must hold: the initial stabilities rise with the rating, and the slow component of the forgetting curve starts above the fast one.

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.

data StabilityWeights Source #

One of the two eight-weight blocks that drive the stability update, one per memory trace.

Constructors

StabilityWeights 

Fields

slowTraceWeights :: Parameters -> StabilityWeights Source #

w7..w14: the block that updates the slow trace.

fastTraceWeights :: Parameters -> StabilityWeights Source #

w15..w22: the block that updates the fast trace.

data CurveWeights Source #

w23..w33: the mixture of two power laws that makes up the FSRS-7 forgetting curve, and the three weights that modulate it.

The last three are stored the way the reference stores them — shifted so that their range starts at zero — and the formulas in FSRS.Algorithm offset them back. The field documentation gives the offset each one carries.

Constructors

CurveWeights 

Fields

  • cwDecayBase1 :: !Double

    w23: sets the fast component's decay, which is also scaled by the fast stability, so unlike every earlier version of FSRS the decay is not a constant.

  • cwDecay2 :: !Double

    w24: the slow component's decay magnitude.

  • cwBase1 :: !Double

    w25: the fast component's recall probability at t == s_fast.

  • cwBase2 :: !Double

    w26: likewise for the slow component at t == s.

  • cwWeight1 :: !Double

    w27: how much the fast component counts in the mixture.

  • cwWeight2 :: !Double

    w28: likewise for the slow component.

  • cwStabilityPower1 :: !Double

    w29; applied as s_fast ** negate cwStabilityPower1.

  • cwStabilityPower2 :: !Double

    w30; applied as s ** cwStabilityPower2.

  • cwDifficultyWeight :: !Double

    w31; the mixture weight of the slow component is scaled by exp ((d - 5) * (cwDifficultyWeight - 0.5)).

  • cwDifficultyDecay :: !Double

    w32; the slow component sees time scaled by exp ((d - 5) * (cwDifficultyDecay - 0.3)), so a hard card experiences time faster while decaying with the same slope.

  • cwStabilityDecay1 :: !Double

    w33; the fast component's decay is scaled by s_fast ** (cwStabilityDecay1 - 0.3).

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.