Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 additions & 0 deletions Statistics/Distribution/Poisson.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@
import Data.Binary (Binary(..))
import Data.Data (Data, Typeable)
import GHC.Generics (Generic)

import qualified System.Random.MWC.Distributions as MWC

import Numeric.SpecFunctions (incompleteGamma,logFactorial)
import Numeric.MathFunctions.Constants (m_neg_inf)


import qualified Statistics.Distribution as D
import qualified Statistics.Distribution.Poisson.Internal as I
import Statistics.Internal
import Control.Monad (liftM)

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 8.10.7

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 8.4.4

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.8

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.12.2

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 8.8.4

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.8.4

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.7

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.2.8

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 8.6.5

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.10.2

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.0.2

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / macos-latest / ghc 9.12.2

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / macos-latest / ghc 9.6.7

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / macos-latest / ghc 9.8.4

The import of ‘Control.Monad’ is redundant

Check warning on line 44 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / macos-latest / ghc 9.10.2

The import of ‘Control.Monad’ is redundant
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this import needed?





newtype PoissonDistribution = PD {
poissonLambda :: Double
} deriving (Eq, Typeable, Data, Generic)

Check warning on line 51 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.12.2

• Deriving ‘Typeable’ has no effect: all types now auto-derive Typeable

Check warning on line 51 in Statistics/Distribution/Poisson.hs

View workflow job for this annotation

GitHub Actions / macos-latest / ghc 9.12.2

• Deriving ‘Typeable’ has no effect: all types now auto-derive Typeable

instance Show PoissonDistribution where
showsPrec i (PD l) = defaultShow1 "poisson" l i
Expand Down Expand Up @@ -93,6 +99,12 @@
instance D.MaybeEntropy PoissonDistribution where
maybeEntropy = Just . D.entropy

instance D.DiscreteGen PoissonDistribution where
genDiscreteVar (PD lambda) = MWC.poisson lambda

instance D.ContGen PoissonDistribution where
genContVar (PD lambda) gen = fromIntegral <$> MWC.poisson lambda gen

Comment on lines +104 to +106
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop ContGen instance. It is discrete distribution after all

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @Shimuuar , i am not able to drop ContGen:

class (DiscreteDistr d, ContGen d) => DiscreteGen d where
  genDiscreteVar :: (StatefulGen g m) => d -> g -> m Int

class (DiscreteDistr d, ContGen d) => DiscreteGen d where

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed! Sorry I forgot about it

-- | Create Poisson distribution.
poisson :: Double -> PoissonDistribution
poisson l = maybe (error $ errMsg l) id $ poissonE l
Expand Down
2 changes: 1 addition & 1 deletion statistics.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ library
build-depends: base >= 4.9 && < 5
--
, math-functions >= 0.3.4.1
, mwc-random >= 0.15.0.0
, mwc-random >= 0.15.3.0
, random >= 1.2
--
, aeson >= 0.6.0.0
Expand Down
Loading