-- | -- Module : Phladiprelio.RulesIntervalsPlus -- Copyright : (c) Oleksandr Zhabenko 2020-2023 -- License : MIT -- Stability : Experimental -- Maintainer : oleksandr.zhabenko@yahoo.com -- -- Additional statistic rules to choose the number of the intervals. {-# LANGUAGE BangPatterns, NoImplicitPrelude #-} module Phladiprelio.RulesIntervalsPlus where import GHC.Base import GHC.List (length, filter) import Phladiprelio.RulesIntervals import Data.Maybe (fromMaybe) import Text.Read (readMaybe) import Data.List (words) getIntervalsNS :: Bool -> String -> [String] -> Int getIntervalsNS lstW xs yss | xs == "s" = sturgesH z | xs == "l" = levynskyiMod z | otherwise = fromMaybe 9 (readMaybe xs::(Maybe Int)) where k = if lstW then 2 else 1 z = length . filter ((> k) . length . words) $ yss {-# INLINE getIntervalsNS #-} getIntervalsN :: String -> [a] -> Int getIntervalsN xs yss | xs == "s" = sturgesH (length yss) | xs == "l" = levynskyiMod (length yss) | otherwise = fromMaybe 9 (readMaybe xs::(Maybe Int)) {-# INLINE getIntervalsN #-}