Skip to content

Commit 9045465

Browse files
Update cabal + add wrapper over MWC (#225)
* update cabal + add wrapper over MWC * Add since annotations and bump version --------- Co-authored-by: Alexey Khudyakov <alexey.skladnoy@gmail.com>
1 parent b628309 commit 9045465

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

Statistics/Distribution/Poisson.hs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,18 @@ import Data.Aeson (FromJSON(..), ToJSON, Value(..), (.:))
3131
import Data.Binary (Binary(..))
3232
import Data.Data (Data, Typeable)
3333
import GHC.Generics (Generic)
34+
35+
import qualified System.Random.MWC.Distributions as MWC
36+
3437
import Numeric.SpecFunctions (incompleteGamma,logFactorial)
3538
import Numeric.MathFunctions.Constants (m_neg_inf)
3639

40+
3741
import qualified Statistics.Distribution as D
3842
import qualified Statistics.Distribution.Poisson.Internal as I
3943
import Statistics.Internal
4044

4145

42-
4346
newtype PoissonDistribution = PD {
4447
poissonLambda :: Double
4548
} deriving (Eq, Typeable, Data, Generic)
@@ -93,6 +96,14 @@ instance D.Entropy PoissonDistribution where
9396
instance D.MaybeEntropy PoissonDistribution where
9497
maybeEntropy = Just . D.entropy
9598

99+
-- | @since 0.16.5.0
100+
instance D.DiscreteGen PoissonDistribution where
101+
genDiscreteVar (PD lambda) = MWC.poisson lambda
102+
103+
-- | @since 0.16.5.0
104+
instance D.ContGen PoissonDistribution where
105+
genContVar (PD lambda) gen = fromIntegral <$> MWC.poisson lambda gen
106+
96107
-- | Create Poisson distribution.
97108
poisson :: Double -> PoissonDistribution
98109
poisson l = maybe (error $ errMsg l) id $ poissonE l

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Changes in 0.16.5.0 [2026.01.09]
2+
3+
* `ContGen` and `DiscreteGen` instances for `Poisson` distributions are added.
4+
5+
16
## Changes in 0.16.4.0 [2025.10.23]
27

38
* Bartlett's test (`Statistics.Test.Bartlett`) and Levene's test

statistics.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cabal-version: 3.0
22
build-type: Simple
33

44
name: statistics
5-
version: 0.16.4.0
5+
version: 0.16.5.0
66
synopsis: A library of statistical types, data, and functions
77
description:
88
This library provides a number of common functions and types useful
@@ -128,7 +128,7 @@ library
128128
build-depends: base >= 4.9 && < 5
129129
--
130130
, math-functions >= 0.3.4.1
131-
, mwc-random >= 0.15.0.0
131+
, mwc-random >= 0.15.3.0
132132
, random >= 1.2
133133
--
134134
, aeson >= 0.6.0.0

0 commit comments

Comments
 (0)