packages feed

uniqueness-periods-vector-stats 0.3.0.0 → 0.4.0.0

raw patch · 4 files changed

+26/−16 lines, 4 filesdep ~basedep ~ghc-primPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, ghc-prim

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -29,3 +29,9 @@ ## 0.3.0.0 -- 2022-05-31  * Third version. Fixed issues with population and sample dispersion evaluation, added for this new functions.++## 0.4.0.0 -- 2023-01-24++* Fourth version. Switched to the NoImplicitPrelude extension usage. Updated the dependencies+  boundaries. Improved the error messages.+
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2020 OleksandrZhabenko+Copyright (c) 2020-2023 Oleksandr Zhabenko  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
Numeric/Stats.hs view
@@ -1,18 +1,22 @@ -- | -- Module      :  Numeric.Stats--- Copyright   :  (c) OleksandrZhabenko 2020-2022+-- Copyright   :  (c) OleksandrZhabenko 2020-2023 -- License     :  MIT -- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com+-- Maintainer  :  oleksandr.zhabenko@yahoo.com -- -- A very basic descriptive statistics. Functions use a tail recursion approach to compute the values and are strict by an accumulator. -{-# LANGUAGE BangPatterns, MagicHash #-}+{-# LANGUAGE BangPatterns, MagicHash, NoImplicitPrelude #-}  module Numeric.Stats where  import GHC.Exts import GHC.Prim+import GHC.Base+import GHC.Real+import GHC.Float+import GHC.Num  -- | Uses GHC unlifted types from @ghc-prim@ package. -- Similar code is here: Don Stewart.  https://donsbot.wordpress.com/2008/05/06/write-haskell-as-fast-as-c-exploiting-strictness-laziness-and-recursion/@@ -23,7 +27,7 @@ mean2F ((F# !x):xs) !s1 !l1 = mean2F xs (plusFloat# s1 x) (l1 +# 1#) mean2F _ !s1 !l1 =  case I# l1 of-  0 -> error "Not defined for the third zero argument. "+  0 -> error "Numeric.Stats.mean2F: Not defined for the third zero argument. "   _  -> F# m    where !m = divideFloat# s1 (int2Float# l1) @@ -36,7 +40,7 @@ mean2D ((D# !x):xs) !s1 !l1 = mean2D xs (s1 +## x) (l1 +# 1#) mean2D _ !s1 !l1 =  case I# l1 of-  0 -> error "Not defined for the third zero argument. "+  0 -> error "Numeric.Stats.mean2D: Not defined for the third zero argument. "   _  -> D# m    where !m = s1 /## int2Double# l1 @@ -75,7 +79,7 @@ -- | Among the 'meanWithDispP', 'meanWithDispF2P' and 'meanWithDispD2P' better to use the last one. meanWithDispP :: (RealFrac a, Floating a) => [a] -> (a,a) meanWithDispP xs@(_:_) = meanWithDispersionP xs 0.0 0.0 0.0 0.0 0.0-meanWithDispP _ = error "Not defined for the empty list. "+meanWithDispP _ = error "Numeric.Stats.meanWithDispP: Not defined for the empty list. " {-# RULES "realfrac/float" meanWithDispP = meanWithDispF2P #-} {-# RULES "realfrac/double" meanWithDispP = meanWithDispD2P #-} {-# INLINE[2] meanWithDispP #-}@@ -83,13 +87,13 @@ -- | Among the 'meanWithDispP', 'meanWithDispF2P' and 'meanWithDispD2P' better to use the last one. meanWithDispF2P :: [Float] -> (Float,Float) meanWithDispF2P xs@(_:_) = meanWithDispersionFP xs 0.0# 0.0# 0#-meanWithDispF2P _ = error "Not defined for the empty list. "+meanWithDispF2P _ = error "Numeric.Stats.meanWithDispF2P: Not defined for the empty list. " {-# INLINE meanWithDispF2P #-}  -- | Among the 'meanWithDispP', 'meanWithDispF2P' and 'meanWithDispD2P' better to use the last one. meanWithDispD2P :: [Double] -> (Double,Double) meanWithDispD2P xs@(x:_) = meanWithDispersionDP xs 0.0## 0.0## 0#-meanWithDispD2P _ = error "Not defined for the empty list. "+meanWithDispD2P _ = error "Numeric.Stats.meanWithDispD2P: Not defined for the empty list. " {-# INLINE meanWithDispD2P #-}  --------------------------------------------------@@ -111,7 +115,7 @@   where mdl (!x:ys) !s1 !s2 !l1 = mdl ys (s1 + x) (s2 + x*x) (l1 + 1)         mdl _ !s1 !s2 !l = (mm, (s2 - mm**2 * l) / (l - 1))           where !mm = s1 / l-meanWithDisp _ = error "Not defined for the list with less than two elements. "+meanWithDisp _ = error "Numeric.Stats.meanWithDisp: Not defined for the list with less than two elements. " {-# RULES "realfrac/float" meanWithDisp = meanWithDispF2 #-} {-# RULES "realfrac/double" meanWithDisp = meanWithDispD2 #-} {-# INLINE[2] meanWithDisp #-}@@ -127,7 +131,7 @@   where mdlF (F# !x:ys) !s1 !s2 !l1 = mdlF ys (plusFloat# s1 x) (plusFloat# s2 (timesFloat# x x)) (l1 +# 1#)         mdlF [] !s1 !s2 !l1 = (F# m, F# (divideFloat# (minusFloat# s2 (timesFloat# (timesFloat# m m) (int2Float# l1))) (int2Float# (l1 -# 1#))))           where !m = divideFloat# s1 (int2Float# l1)-meanWithDispF2 _ = error "Not defined for the list with less than two elements. "+meanWithDispF2 _ = error "Numeric.Stats.meanWithDispF2: Not defined for the list with less than two elements. " {-# INLINE meanWithDispF2 #-}  -- | One-pass and tail-recursive realization for the pair of the mean and dispersion. Is vulnerable to the floating-point cancellation errors.@@ -141,5 +145,5 @@   where mdlD ((D# !x):xs) !s1 !s2 !l1 = mdlD xs (s1 +## x) (s2 +## (x *## x)) (l1 +# 1#)         mdlD [] !s1 !s2 !l1 = (D# m, D# ((s2 -## m *## m *## int2Double# l1) /## (int2Double# (l1 -# 1#))))           where !m = s1 /## int2Double# l1-meanWithDispD2 _ = error "Not defined for the list with less than two elements. "+meanWithDispD2 _ = error "Numeric.Stats.meanWithDispD2: Not defined for the list with less than two elements. " {-# INLINE meanWithDispD2 #-}
uniqueness-periods-vector-stats.cabal view
@@ -2,14 +2,14 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/  name:                uniqueness-periods-vector-stats-version:             0.3.0.0+version:             0.4.0.0 synopsis:            A very basic descriptive statistics. description:         A very basic descriptive statistics. Functions use a tail recursion approach to compute the values and are strict by an accumulator. homepage:            https://hackage.haskell.org/package/uniqueness-periods-vector-stats license:             MIT license-file:        LICENSE author:              OleksandrZhabenko-maintainer:          olexandr543@yahoo.com+maintainer:          oleksandr.zhabenko@yahoo.com copyright:           Oleksandr Zhabenko category:            Math,Data build-type:          Simple@@ -19,7 +19,7 @@ library   exposed-modules:     Numeric.Stats   -- other-modules:-  other-extensions:    BangPatterns, MagicHash-  build-depends:       base >=4.7 && <5, ghc-prim >=0.3.1 && <1+  other-extensions:    BangPatterns, MagicHash, NoImplicitPrelude+  build-depends:       base >=4.13 && <5, ghc-prim >=0.5.3 && <1   -- hs-source-dirs:   default-language:    Haskell2010