Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
18 changes: 12 additions & 6 deletions Statistics/Test/ChiSquared.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
import Statistics.Distribution
import Statistics.Distribution.ChiSquared
import Statistics.Function (square)
import Statistics.Sample.Internal (sum)

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.2.8

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 8.4.4

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 8.8.4

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 8.6.5

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 8.10.7

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.7

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.8.4

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.8

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.10.2

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / macos-latest / ghc 9.8.4

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / macos-latest / ghc 9.6.7

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.0.2

The import of ‘Statistics.Sample.Internal’ is redundant

Check warning on line 14 in Statistics/Test/ChiSquared.hs

View workflow job for this annotation

GitHub Actions / macos-latest / ghc 9.10.2

The import of ‘Statistics.Sample.Internal’ is redundant
import Statistics.Test.Types
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,
-- expected number of events). Both must be positive.
--
-- 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
Expand All @@ -44,7 +44,10 @@
| 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
Expand All @@ -56,7 +59,7 @@
-- | 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.
Expand All @@ -71,5 +74,8 @@
| 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
14 changes: 7 additions & 7 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 4 additions & 2 deletions statistics.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading