packages feed

regression-simple 0.2.1 → 0.2.2

raw patch · 5 files changed

+33/−68 lines, 5 filesdep −math-functionsdep ~addep ~basedep ~deepseqPVP ok

version bump matches the API change (PVP)

Dependencies removed: math-functions

Dependency ranges changed: ad, base, deepseq, semigroups, statistics, tasty

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,3 +1,9 @@+# 0.2.2++* Support GHC-9.14+* Drop support for GHCs prior 9.2+* Update dependencies (also lower bounds)+ # 0.2.1  * Better lambda0 guesses, hopefully
regression-simple.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               regression-simple-version:            0.2.1+version:            0.2.2 synopsis:           Simple linear and quadratic regression category:           Math description:@@ -25,22 +25,13 @@   gnuplot/quad.dat  tested-with:-  GHC ==7.0.4-   || ==7.2.2-   || ==7.4.2-   || ==7.6.3-   || ==7.8.4-   || ==7.10.3-   || ==8.0.2-   || ==8.2.2-   || ==8.4.4-   || ==8.6.5-   || ==8.8.4-   || ==8.10.7-   || ==9.0.2-   || ==9.2.7-   || ==9.4.5-   || ==9.6.1+  GHC ==9.2.8+   || ==9.4.8+   || ==9.6.7+   || ==9.8.4+   || ==9.10.3+   || ==9.12.4+   || ==9.14.1  source-repository head   type:     git@@ -56,11 +47,8 @@     Numeric.KBN    build-depends:-    , base     >=4.3 && <4.19-    , deepseq--  if !impl(ghc >=8.0)-    build-depends: semigroups >=0.18.5 && <0.21+    , base     >=4.16.4.0 && <4.23+    , deepseq  >=1.4.6.1  && <1.6    x-docspec-extra-packages: math-functions statistics ad @@ -71,7 +59,7 @@   type:             exitcode-stdio-1.0   main-is:          generate-test-data.hs   build-depends:-    , base+    , base <5     , splitmix  ^>=0.1.0.4  test-suite regression-simple-tests@@ -85,14 +73,13 @@     , regression-simple    build-depends:-    , tasty           ^>=1.4.0.1-    , tasty-hunit     ^>=0.10.0.3+    , tasty        ^>=1.5.4+    , tasty-hunit  ^>=0.10.0.3    if impl(ghc >=7.4)     build-depends:-      , ad              >=4.4.1    && <4.6-      , math-functions  ^>=0.3.4.2-      , statistics      ^>=0.10.2.0 || ^>=0.15.2.0 || ^>=0.16.0.1+      , ad              ^>=4.5.6+      , statistics      ^>=0.16.5.0    if !impl(ghc >=8.0)     build-depends: semigroups
src/Math/Regression/Simple.hs view
@@ -21,6 +21,9 @@ -- Package has been tested to return similar results as @fit@ functionality in @gnuplot@ -- (L-M doesn't always converge to exactly the same points in parameter space). --+-- Functions in this module which are polymorphic over 'Foldable' use strict 'F.foldl''.+-- This works well for ordinary lists and vectors, but might be sub-optimal for some other foldables.+-- module Math.Regression.Simple (     -- * Linear regression     linear,@@ -133,6 +136,14 @@ -- >>> let input2 = [(0.1, 1.2), (1.3, 3.1), (1.9, 4.9), (3.0, 7.1), (4.1, 9.0)] -- >>> PP $ linear id input2 -- V2 2.0063 0.88685+--+-- 'linear' (and other functions in this module) are susceptible to [catastropic cancellation](https://en.wikipedia.org/wiki/Catastrophic_cancellation),+-- I haven't yet experienced this in practice. If you do, please open an issue.+--+-- >>> let input2 = map (\(x,y) -> (x + 1e8, y + 1e8)) [(0.1, 1.2), (1.3, 3.1), (1.9, 4.9), (3.0, 7.1), (4.1, 9.0)]+-- >>> PP $ linear id input2+-- V2 1.5000 (-67108864)+-- -- linear :: F.Foldable f => (a -> (Double, Double)) -> f a -> V2 linear f = fitParams . linearFit f
test/generate-test-data.hs view
@@ -1,3 +1,4 @@+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} module Main where  import Control.Monad      (unless)
test/regression-simple-tests.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP               #-} {-# LANGUAGE DeriveFoldable    #-} {-# LANGUAGE DeriveFunctor     #-} {-# LANGUAGE DeriveTraversable #-}@@ -12,11 +11,9 @@ import qualified Data.List.NonEmpty                 as NE import qualified Data.Traversable                   as T -#if __GLASGOW_HASKELL__ >= 704 import qualified Numeric.AD.Mode.Reverse.Double     as AD import qualified Statistics.Distribution            as S import qualified Statistics.Distribution.ChiSquared as S-#endif  import Math.Regression.Simple import Numeric.KBN            (sumKBN)@@ -70,10 +67,7 @@         assertEqual "errors" (V2 7.722e-2 0.91882) (round' (fitErrors fit))         assertEqual "ndf"    18                    (round' (fitNDF fit))         assertEqual "wssr"   38.8345               (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         assertEqual "P"      2.999e-3              (round' (1 - S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)))-#endif      , testCase "xy-errors" $ do         linearData <- load@@ -82,10 +76,7 @@         assertEqual "errors" (V2 7.6542e-2 0.90917) (round' (fitErrors fit))         assertEqual "ndf"    18                     (round' (fitNDF fit))         assertEqual "wssr"   29.141                 (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         assertEqual "P"      4.6683e-2              (round' (1 - S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)))-#endif      , testCase "yx-errors" $ do         linearData <- load@@ -94,10 +85,7 @@         assertEqual "errors" (V2 8.5724e-3 0.34855)  (round' (fitErrors fit))         assertEqual "ndf"    18                      (round' (fitNDF fit))         assertEqual "wssr"   29.3171                 (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         assertEqual "P"      4.4639e-2               (round' (1 - S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)))-#endif     ]  nth :: Int -> NE.NonEmpty a -> a@@ -126,11 +114,8 @@         assertEqual "errors" (V3 9.7603e-3 0.21331 0.99362)  (round' (fitErrors fit))         assertEqual "ndf"    17                              (round' (fitNDF fit))         assertEqual "wssr"   16.793                          (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         let q = S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)         assertEqual "P"      0.46847                         (round' (1 - q))-#endif      , testCase "xy-errors" $ do         quadraticData <- load@@ -139,11 +124,8 @@         assertEqual "errors" (V3 9.9372e-3 0.22027 1.06196)  (round' (fitErrors fit))         assertEqual "ndf"    17                              (round' (fitNDF fit))         assertEqual "wssr"   15.6318                         (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         let q = S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)         assertEqual "P"      0.55007                         (round' (1 - q))-#endif     ]  -------------------------------------------------------------------------------@@ -173,10 +155,7 @@         assertEqual "errors" 3.7604e-2 (round' (fitErrors fit))         assertEqual "ndf"    19        (round' (fitNDF fit))         assertEqual "wssr"   40.9918   (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         assertEqual "P"      2.4195e-3 (round' (1 - S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)))-#endif      , testCase "xy-errors" $ do         linearData <- load@@ -187,10 +166,7 @@         assertEqual "errors" 3.7477e-2 (round' (fitErrors fit))         assertEqual "ndf"    19        (round' (fitNDF fit))         assertEqual "wssr"   30.7021   (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         assertEqual "P"      4.3516e-2 (round' (1 - S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)))-#endif      , testCase "issue-8" $ do         let dat = [(1e5,1e6),(1e6,1e7)] :: [(Double, Double)]@@ -235,10 +211,7 @@         assertEqual "errors" (V2 7.6542e-2 0.90917) (round' (fitErrors fit))         assertEqual "ndf"    18                     (round' (fitNDF fit))         assertEqual "wssr"   29.141                 (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         assertEqual "P"      4.6683e-2              (round' (1 - S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)))-#endif      , testCase "yx-errors" $ do         -- with x and y flipped:@@ -250,12 +223,8 @@         assertEqual "errors" (V2 8.5742e-3 0.34862)  (round' (fitErrors fit))         assertEqual "ndf"    18                      (round' (fitNDF fit))         assertEqual "wssr"   29.2361                 (round' (fitWSSR fit))--#if __GLASGOW_HASKELL__ >= 704         assertEqual "P"      4.5568e-2               (round' (1 - S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)))-#endif -#if __GLASGOW_HASKELL__ >= 704     , testCase "orear-example" $ do         let orearData :: [(Double, Double, Double, Double)]             orearData = zip4@@ -286,7 +255,6 @@         assertEqual "wssr"   2.18668                 (round' (fitWSSR fit))          assertEqual "P"      0.53458                 (round' (1 - S.cumulative (S.chiSquared (fitNDF fit)) (fitWSSR fit)))-#endif      ] @@ -297,21 +265,13 @@ scaleF (H2 a x) = a * x + 5  scaleGrad' :: H2 Double -> (Double, H2 Double)-#if __GLASGOW_HASKELL__ >= 704 scaleGrad' = AD.grad' scaleF-#else-scaleGrad' (H2 a x) = (a * x + 5, H2 x a)-#endif  linearF :: Num a => H3 a -> a linearF (H3 a b x) = a * x + b  linearGrad' :: H3 Double -> (Double, H3 Double)-#if __GLASGOW_HASKELL__ >= 704 linearGrad' = AD.grad' linearF-#else-linearGrad' (H3 a b x) = (a * x + b, H3 x 1 a)-#endif  orearF :: Fractional a => H3 a -> a orearF (H3 a b x) = a * x - b / x