packages feed

dirichlet 0.1.0.6 → 0.1.0.7

raw patch · 5 files changed

+57/−47 lines, 5 filesdep +randomdep −primitivePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: random

Dependencies removed: primitive

API changes (from Hackage documentation)

- Statistics.Distribution.Dirichlet: dirichletSample :: PrimMonad m => DirichletDistribution -> Gen (PrimState m) -> m (Vector Double)
+ Statistics.Distribution.Dirichlet: dirichletSample :: StatefulGen g m => DirichletDistribution -> g -> m (Vector Double)
- Statistics.Distribution.Dirichlet: dirichletSampleSymmetric :: PrimMonad m => DirichletDistributionSymmetric -> Gen (PrimState m) -> m (Vector Double)
+ Statistics.Distribution.Dirichlet: dirichletSampleSymmetric :: StatefulGen g m => DirichletDistributionSymmetric -> g -> m (Vector Double)

Files

ChangeLog.md view
@@ -5,6 +5,12 @@ ## Unreleased changes  +## 0.1.0.7++-   Random 1.2 (random sampling function has more general type).+-   GHC 9.2.3.++ ## 0.1.0.6  -   Tooling.
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2021, Dominik Schrempf+Copyright 2021 Dominik Schrempf  All rights reserved. 
dirichlet.cabal view
@@ -1,46 +1,51 @@-cabal-version:       3.0-name:                dirichlet-version:             0.1.0.6-synopsis:            Multivariate Dirichlet distribution-description:         Please see the README on GitHub at <https://github.com/dschrempf/dirichlet#readme>-homepage:            https://github.com/dschrempf/dirichlet-bug-reports:         https://github.com/dschrempf/dirichlet-license:             BSD-3-Clause-license-file:        LICENSE-author:              Dominik Schrempf-maintainer:          dominik.schrempf@gmail.com-copyright:           Dominik Schrempf 2021-category:            Math-build-type:          Simple+cabal-version:      3.0+name:               dirichlet+version:            0.1.0.7+synopsis:           Multivariate Dirichlet distribution+description:+  Please see the README on GitHub at <https://github.com/dschrempf/dirichlet#readme> +homepage:           https://github.com/dschrempf/dirichlet+bug-reports:        https://github.com/dschrempf/dirichlet+license:            BSD-3-Clause+license-file:       LICENSE+author:             Dominik Schrempf+maintainer:         dominik.schrempf@gmail.com+copyright:          2021 Dominik Schrempf+category:           Math+build-type:         Simple extra-source-files:-  README.md   ChangeLog.md+  README.md  library-  exposed-modules:     Statistics.Distribution.Dirichlet+  exposed-modules:  Statistics.Distribution.Dirichlet+   -- other-modules:   -- other-extensions:-  ghc-options:       -Wall -Wunused-packages-  build-depends:       base < 5-                     , log-domain-                     , math-functions-                     , mwc-random-                     , primitive-                     , vector-  hs-source-dirs:      src-  default-language:    Haskell2010+  ghc-options:      -Wall -Wunused-packages+  build-depends:+    , base            <5+    , log-domain+    , math-functions+    , mwc-random+    , random+    , vector +  hs-source-dirs:   src+  default-language: Haskell2010+ test-suite dirichlet-test-  default-language:    Haskell2010-  type:                exitcode-stdio-1.0-  hs-source-dirs:      test-  main-is:             Spec.hs-  other-modules:       Statistics.Distribution.DirichletSpec-  ghc-options:       -Wall -Wunused-packages-  build-depends:       base < 5-                     , dirichlet-                     , hspec-                     , log-domain-                     , mwc-random-                     , vector+  default-language: Haskell2010+  type:             exitcode-stdio-1.0+  hs-source-dirs:   test+  main-is:          Spec.hs+  other-modules:    Statistics.Distribution.DirichletSpec+  ghc-options:      -Wall -Wunused-packages+  build-depends:+    , base        <5+    , dirichlet+    , hspec+    , log-domain+    , random+    , vector
src/Statistics/Distribution/Dirichlet.hs view
@@ -1,7 +1,7 @@ -- | -- Module      :  Statistics.Distribution.Dirichlet -- Description :  Multivariate Dirichlet distribution--- Copyright   :  (c) Dominik Schrempf, 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -24,12 +24,11 @@   ) where -import Control.Monad.Primitive import qualified Data.Vector.Unboxed as V import Numeric.Log import Numeric.SpecFunctions-import System.Random.MWC import System.Random.MWC.Distributions+import System.Random.Stateful  -- | The [Dirichlet distribution](https://en.wikipedia.org/wiki/Dirichlet_distribution). data DirichletDistribution = DirichletDistribution@@ -94,7 +93,7 @@     logXsPow = V.sum $ V.zipWith (\a x -> log $ x ** (a - 1.0)) as xs  -- | Sample a value vector from the Dirichlet distribution.-dirichletSample :: PrimMonad m => DirichletDistribution -> Gen (PrimState m) -> m (V.Vector Double)+dirichletSample :: StatefulGen g m => DirichletDistribution -> g -> m (V.Vector Double) dirichletSample (DirichletDistribution as _ _) g = do   ys <- V.mapM (\a -> gamma a 1.0 g) as   let s = V.sum ys@@ -151,9 +150,9 @@  -- | Sample a value vector from the symmetric Dirichlet distribution. dirichletSampleSymmetric ::-  PrimMonad m =>+  StatefulGen g m =>   DirichletDistributionSymmetric ->-  Gen (PrimState m) ->+  g ->   m (V.Vector Double) dirichletSampleSymmetric (DirichletDistributionSymmetric a k _) g = do   ys <- V.replicateM k (gamma a 1.0 g)
test/Statistics/Distribution/DirichletSpec.hs view
@@ -1,7 +1,7 @@ -- | -- Module      :  DirichletSpec -- Description :  Unit tests for DirichletSpec--- Copyright   :  (c) Dominik Schrempf, 2021+-- Copyright   :  2021 Dominik Schrempf -- License     :  GPL-3.0-or-later -- -- Maintainer  :  dominik.schrempf@gmail.com@@ -19,7 +19,7 @@ import qualified Data.Vector.Unboxed as V import Numeric.Log hiding (sum) import Statistics.Distribution.Dirichlet-import System.Random.MWC+import System.Random.Stateful import Test.Hspec  eps :: Double@@ -68,7 +68,7 @@       rWrongDim `shouldBe` 0   describe "dirichletSample" $ do     it "returns valid value vectors with expected mean" $ do-      g <- create+      g <- newIOGenM $ mkStdGen 0       let ddSym10 = ddSym 10 10       xs <- replicateM 1000 (dirichletSample ddSym10 g)       map V.length xs `shouldBe` replicate 1000 10