chore: extende random distribution with nudges

This commit is contained in:
Wolfgang Witt 2021-03-02 15:01:21 +01:00 committed by Wolfgang Witt
parent b36a15c0b2
commit 9b0adab023

View File

@ -51,7 +51,6 @@ import qualified Data.List as List
import Data.Either.Combinators (maybeToRight)
import Data.ExtendedReal
import Data.Ratio (Ratio)
import qualified Data.RFC5051 as RFC5051
@ -306,8 +305,11 @@ examAutoOccurrence (hash -> seed) rule ExamAutoOccurrenceConfig{..} occurrences
decreaseBiggestOutlier n currentOccurrences = decreaseBiggestOutlier (pred n)
$ Map.update predToPositive biggestOutlier currentOccurrences
where
currentRatios :: Map ExamOccurrenceId (Ratio Natural)
currentRatios = Map.merge Map.dropMissing Map.dropMissing (Map.zipWithMatched $ const (%)) currentOccurrences occurrencesMap
currentRatios :: Map ExamOccurrenceId Rational
currentRatios = Map.merge Map.dropMissing Map.dropMissing (Map.zipWithMatched calculateRatio)
currentOccurrences occurrencesMap
calculateRatio :: ExamOccurrenceId -> Natural -> Natural -> Rational
calculateRatio k c m = fromIntegral c % fromIntegral m - eaocNudgeSize * fromIntegral (lineNudges k)
biggestOutlier :: ExamOccurrenceId
biggestOutlier = fst . List.maximumBy (comparing $ view _2) $ Map.toList currentRatios
extraCapacity :: Natural