dirichlet 0.1.0.2 → 0.1.0.4
raw patch · 2 files changed
+24/−14 lines, 2 filesdep ~basedep ~hspecdep ~log-domainPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, hspec, log-domain, math-functions, mwc-random, primitive, vector
API changes (from Hackage documentation)
Files
- dirichlet.cabal +12/−12
- src/Statistics/Distribution/Dirichlet.hs +12/−2
dirichlet.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: dirichlet-version: 0.1.0.2+version: 0.1.0.4 license: BSD-3-Clause license-file: LICENSE copyright: Dominik Schrempf 2020@@ -24,12 +24,12 @@ default-language: Haskell2010 ghc-options: -Wall -Wunused-packages build-depends:- base >=4.14.1.0 && <4.15,- log-domain ==0.13.*,- math-functions >=0.3.4.1 && <0.4,- mwc-random >=0.14.0.0 && <0.15,- primitive >=0.7.1.0 && <0.8,- vector >=0.12.1.2 && <0.13+ base >=4.14.1.0 && <5,+ log-domain >=0.13.1,+ math-functions >=0.3.4.2,+ mwc-random >=0.14.0.0,+ primitive >=0.7.1.0,+ vector >=0.12.3.0 test-suite dirichlet-test type: exitcode-stdio-1.0@@ -39,9 +39,9 @@ default-language: Haskell2010 ghc-options: -Wall -Wunused-packages build-depends:- base >=4.14.1.0 && <4.15,+ base >=4.14.1.0 && <5, dirichlet -any,- hspec >=2.7.4 && <2.8,- log-domain ==0.13.*,- mwc-random >=0.14.0.0 && <0.15,- vector >=0.12.1.2 && <0.13+ hspec >=2.7.10,+ log-domain >=0.13.1,+ mwc-random >=0.14.0.0,+ vector >=0.12.3.0
src/Statistics/Distribution/Dirichlet.hs view
@@ -31,7 +31,7 @@ import System.Random.MWC import System.Random.MWC.Distributions --- | The Dirichlet distribution is identified by a vector of parameter values.+-- | The [Dirichlet distribution](https://en.wikipedia.org/wiki/Dirichlet_distribution). data DirichletDistribution = DirichletDistribution { ddGetParameters :: V.Vector Double, _getDimension :: Int,@@ -53,7 +53,9 @@ -- | Create a Dirichlet distribution from the given parameter vector. -- -- Return Left if:+-- -- - The parameter vector has less then two elements.+-- -- - One or more parameters are negative or zero. dirichletDistribution :: V.Vector Double -> Either String DirichletDistribution dirichletDistribution v@@ -76,8 +78,11 @@ -- | Density of the Dirichlet distribution evaluated at a given value vector. -- -- Return 0 if:+-- -- - The value vector has a different length than the parameter vector.+-- -- - The value vector has elements being negative or zero.+-- -- - The value vector does not sum to 1.0 (with tolerance @eps = 1e-14@). dirichletDensity :: DirichletDistribution -> V.Vector Double -> Log Double dirichletDensity (DirichletDistribution as k c) xs@@ -95,7 +100,7 @@ let s = V.sum ys return $ V.map (/ s) ys --- | The Dirichlet distribution is identified by a vector of parameter values.+-- | See 'DirichletDistribution' but with parameter vector @replicate DIM VAL@. data DirichletDistributionSymmetric = DirichletDistributionSymmetric { ddSymGetParameter :: Double, _symGetDimension :: Int,@@ -113,7 +118,9 @@ -- | Create a symmetric Dirichlet distribution of given dimension and parameter. -- -- Return Left if:+-- -- - The given dimension is smaller than two.+-- -- - The parameter is negative or zero. dirichletDistributionSymmetric :: Int -> Double -> Either String DirichletDistributionSymmetric dirichletDistributionSymmetric k a@@ -127,8 +134,11 @@ -- vector. -- -- Return 0 if:+-- -- - The value vector has a different dimension.+-- -- - The value vector has elements being negative or zero.+-- -- - The value vector does not sum to 1.0 (with tolerance @eps = 1e-14@). dirichletDensitySymmetric :: DirichletDistributionSymmetric -> V.Vector Double -> Log Double dirichletDensitySymmetric (DirichletDistributionSymmetric a k c) xs