diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34b6343..a42596f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: name: Cache ~/.cabal/store with: path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }} - key: ${{ runner.os }}-${{ matrix.ghc }}--${{ github.Shah }}-CACHE_V3 + key: ${{ runner.os }}-${{ matrix.ghc }}---CACHE_V3 # ---------------- - name: "Install PAPI" run: | diff --git a/Statistics/Test/ChiSquared.hs b/Statistics/Test/ChiSquared.hs index c5be9fc..1c7ed9e 100644 --- a/Statistics/Test/ChiSquared.hs +++ b/Statistics/Test/ChiSquared.hs @@ -17,8 +17,8 @@ import Statistics.Types import qualified Data.Vector as V import qualified Data.Vector.Generic as G import qualified Data.Vector.Unboxed as U - - +import qualified Data.Vector.Fusion.Bundle as F +import qualified Numeric.Sum as Sum -- | Generic form of Pearson chi squared tests for binned data. Data -- sample is supplied in form of tuples (observed quantity, @@ -26,7 +26,7 @@ import qualified Data.Vector.Unboxed as U -- -- This test should be used only if all bins have expected values of -- at least 5. -chi2test :: (G.Vector v (Int,Double), G.Vector v Double) +chi2test :: (G.Vector v (Int,Double)) => Int -- ^ Number of additional degrees of -- freedom. One degree of freedom -- is due to the fact that the are @@ -44,7 +44,10 @@ chi2test ndf vec | otherwise = Nothing where n = G.length vec - ndf - 1 - chi2 = sum $ G.map (\(o,e) -> square (fromIntegral o - e) / e) vec + chi2 = Sum.kbn + $ F.foldl' Sum.add Sum.zero + $ F.map (\(o,e) -> square (fromIntegral o - e) / e) + $ G.stream vec d = chiSquared n {-# INLINABLE chi2test #-} {-# SPECIALIZE @@ -56,7 +59,7 @@ chi2test ndf vec -- | Chi squared test for data with normal errors. Data is supplied in -- form of pair (observation with error, and expectation). chi2testCont - :: (G.Vector v (Estimate NormalErr Double, Double), G.Vector v Double) + :: (G.Vector v (Estimate NormalErr Double, Double)) => Int -- ^ Number of additional -- degrees of freedom. -> v (Estimate NormalErr Double, Double) -- ^ Observation and expectation. @@ -71,5 +74,8 @@ chi2testCont ndf vec | otherwise = Nothing where n = G.length vec - ndf - 1 - chi2 = sum $ G.map (\(Estimate o (NormalErr s),e) -> square (o - e) / s) vec + chi2 = Sum.kbn + $ F.foldl' Sum.add Sum.zero + $ F.map (\(Estimate o (NormalErr s),e) -> square (o - e) / s) + $ G.stream vec d = chiSquared n diff --git a/changelog.md b/changelog.md index dd1f56c..bff0b21 100644 --- a/changelog.md +++ b/changelog.md @@ -1,12 +1,12 @@ -## Unreleased +## Changes in 0.16.4.0 [2025.10.23] -- **New Features**: - - Implemented Bartlett's test (`Statistics.Test.Bartlett`) for homogeneity of variances. - - Implemented Levene's test (`Statistics.Test.Levene`) for homogeneity of variances. - - Resolves [#137](https://github.com/haskell/statistics/issues/137). + * Bartlett's test (`Statistics.Test.Bartlett`) and Levene's test + (`Statistics.Test.Levene`) for homogeneity of variances is added. + + * Improved performance in calculation of moments. + + * Improved precision in calculation of `logDensity` of Student T distribution. -- **Documentation**: - - Added usage examples and Haddock comments for both tests. ## Changes in 0.16.3.0 diff --git a/statistics.cabal b/statistics.cabal index 8f01857..4bb5c9f 100644 --- a/statistics.cabal +++ b/statistics.cabal @@ -2,7 +2,7 @@ cabal-version: 3.0 build-type: Simple name: statistics -version: 0.16.3.0 +version: 0.16.4.0 synopsis: A library of statistical types, data, and functions description: This library provides a number of common functions and types useful @@ -137,7 +137,7 @@ library , binary >= 0.5.1.0 , primitive >= 0.3 , dense-linear-algebra >= 0.1 && <0.2 - , parallel >= 3.2.2.0 && <3.3 + , parallel >= 3.2.2.0 && <3.4 , vector >= 0.10 , vector-algorithms >= 0.4 , vector-th-unbox @@ -174,6 +174,8 @@ test-suite statistics-tests Tests.Quantile ghc-options: -Wall -threaded -rtsopts -fsimpl-tick-factor=500 + if impl(ghc >= 9.8) + ghc-options: -Wno-x-partial build-depends: base , statistics , dense-linear-algebra