hmatrix-gsl-stats 0.4 → 0.4.1
raw patch · 4 files changed
+43/−36 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Numeric.GSL.Distribution.Discrete: density_1p :: OneParamDist -> DistFunc -> Double -> Int -> Double
+ Numeric.GSL.Distribution.Discrete: density_1p :: OneParamDist -> DistFunc -> Double -> Word32 -> Double
- Numeric.GSL.Distribution.Discrete: density_2p :: TwoParamDist -> DistFunc -> Double -> Int -> Int -> Double
+ Numeric.GSL.Distribution.Discrete: density_2p :: TwoParamDist -> DistFunc -> Double -> Word32 -> Word32 -> Double
- Numeric.GSL.Distribution.Discrete: density_3p :: ThreeParamDist -> DistFunc -> Int -> Int -> Int -> Int -> Double
+ Numeric.GSL.Distribution.Discrete: density_3p :: ThreeParamDist -> DistFunc -> Word32 -> Word32 -> Word32 -> Word32 -> Double
- Numeric.GSL.Distribution.Discrete: density_mp :: MultiParamDist -> DistFunc -> Vector Double -> Vector Int -> Double
+ Numeric.GSL.Distribution.Discrete: density_mp :: MultiParamDist -> DistFunc -> Vector Double -> Vector Word32 -> Double
- Numeric.GSL.Distribution.Discrete: random_1p :: OneParamDist -> Int -> Double -> Int
+ Numeric.GSL.Distribution.Discrete: random_1p :: OneParamDist -> Int -> Double -> Word32
- Numeric.GSL.Distribution.Discrete: random_1p_v :: OneParamDist -> Int -> Double -> Int -> Vector Int
+ Numeric.GSL.Distribution.Discrete: random_1p_v :: OneParamDist -> Int -> Double -> Int -> Vector Word32
- Numeric.GSL.Distribution.Discrete: random_2p :: TwoParamDist -> Int -> Double -> Int -> Int
+ Numeric.GSL.Distribution.Discrete: random_2p :: TwoParamDist -> Int -> Double -> Word32 -> Word32
- Numeric.GSL.Distribution.Discrete: random_2p_v :: TwoParamDist -> Int -> Double -> Int -> Int -> Vector Int
+ Numeric.GSL.Distribution.Discrete: random_2p_v :: TwoParamDist -> Int -> Double -> Word32 -> Int -> Vector Word32
- Numeric.GSL.Distribution.Discrete: random_3p :: ThreeParamDist -> Int -> Int -> Int -> Int -> Int
+ Numeric.GSL.Distribution.Discrete: random_3p :: ThreeParamDist -> Int -> Word32 -> Word32 -> Word32 -> Word32
- Numeric.GSL.Distribution.Discrete: random_3p_v :: ThreeParamDist -> Int -> Int -> Int -> Int -> Int -> Vector Int
+ Numeric.GSL.Distribution.Discrete: random_3p_v :: ThreeParamDist -> Int -> Word32 -> Word32 -> Word32 -> Int -> Vector Word32
- Numeric.GSL.Distribution.Discrete: random_mp :: MultiParamDist -> Int -> Int -> Vector Double -> Vector Int
+ Numeric.GSL.Distribution.Discrete: random_mp :: MultiParamDist -> Int -> Word32 -> Vector Double -> Vector Word32
Files
- CHANGES +3/−0
- hmatrix-gsl-stats.cabal +1/−1
- lib/Numeric/GSL/Distribution/Common.hs +3/−0
- lib/Numeric/GSL/Distribution/Discrete.hs +36/−35
CHANGES view
@@ -91,3 +91,6 @@ 0.4: added RNG type to pass between calls to RNG++0.4.1:+ changed discrete distribution return from Int to Word32 to match C uint
hmatrix-gsl-stats.cabal view
@@ -1,5 +1,5 @@ Name: hmatrix-gsl-stats-Version: 0.4+Version: 0.4.1 License: BSD3 License-file: LICENSE Copyright: (c) A.V.H. McPhail 2010, 2011, 2013, 2015
lib/Numeric/GSL/Distribution/Common.hs view
@@ -12,6 +12,9 @@ -- -- <http://www.gnu.org/software/gsl/manual/> --+-- FOr information on how to set environment variables to set RNG type and seed+-- see <http://www.gnu.org/software/gsl/manual/html_node/Random-number-environment-variables.html#Random-number-environment-variables>+-- ----------------------------------------------------------------------------- module Numeric.GSL.Distribution.Common (
lib/Numeric/GSL/Distribution/Discrete.hs view
@@ -30,6 +30,7 @@ import Data.Packed.Vector --import Data.Packed.Matrix hiding(toLists) import Data.Packed.Development+import Data.Word --import Numeric.LinearAlgebra.Linear @@ -83,7 +84,7 @@ random_1p :: OneParamDist -- ^ distribution type -> Int -- ^ random seed -> Double -- ^ parameter- -> Int -- ^ result+ -> Word32 -- ^ result random_1p d s p = unsafePerformIO $ alloca $ \r -> do check "random1p" $ distribution_discrete_one_param (fromIntegral s) (fromei d) p r@@ -94,7 +95,7 @@ random_1p_s :: RNG -- ^ RNG -> OneParamDist -- ^ distribution type -> Double -- ^ parameter- -> IO Int -- ^ result+ -> IO Word32 -- ^ result random_1p_s (RNG rng) d p = do alloca $ \r -> withForeignPtr rng $ \rg -> do@@ -107,7 +108,7 @@ -> Int -- ^ random seed -> Double -- ^ parameter -> Int -- ^ number of samples- -> Vector Int -- ^ result+ -> Vector Word32 -- ^ result random_1p_v d s p l = unsafePerformIO $ do r <- createVector l app1 (distribution_discrete_one_param_v (fromIntegral s) (fromei d) p) vec r "random_1p_v"@@ -117,7 +118,7 @@ density_1p :: OneParamDist -- ^ density type -> DistFunc -- ^ distribution function type -> Double -- ^ parameter- -> Int -- ^ value+ -> Word32 -- ^ value -> Double -- ^ result density_1p d f p x = unsafePerformIO $ do case d of @@ -144,8 +145,8 @@ random_2p :: TwoParamDist -- ^ distribution type -> Int -- ^ random seed -> Double -- ^ parameter 1- -> Int -- ^ parameter 2- -> Int -- ^ result+ -> Word32 -- ^ parameter 2+ -> Word32 -- ^ result random_2p d s p1 p2 = unsafePerformIO $ alloca $ \r -> do check "random2p" $ distribution_discrete_two_param (fromIntegral s) (fromei d) p1 (fromIntegral p2) r@@ -156,8 +157,8 @@ random_2p_s :: RNG -- ^ RNG -> TwoParamDist -- ^ distribution type -> Double -- ^ parameter 1- -> Int -- ^ parameter 2- -> IO Int -- ^ result+ -> Word32 -- ^ parameter 2+ -> IO Word32 -- ^ result random_2p_s (RNG rng) d p1 p2 = alloca $ \r -> withForeignPtr rng $ \rg -> do check "random2p_s" $ distribution_discrete_two_param_s rg (fromei d) p1 (fromIntegral p2) r@@ -168,9 +169,9 @@ random_2p_v :: TwoParamDist -- ^ distribution type -> Int -- ^ random seed -> Double -- ^ parameter 1- -> Int -- ^ parameter 2+ -> Word32 -- ^ parameter 2 -> Int -- ^ number of samples- -> Vector Int -- ^ result+ -> Vector Word32 -- ^ result random_2p_v d s p1 p2 l = unsafePerformIO $ do r <- createVector l app1 (distribution_discrete_two_param_v (fromIntegral s) (fromei d) p1 (fromIntegral p2)) vec r "random_2p_v"@@ -180,8 +181,8 @@ density_2p :: TwoParamDist -- ^ density type -> DistFunc -- ^ distribution function type -> Double -- ^ parameter 1- -> Int -- ^ parameter 2- -> Int -- ^ value+ -> Word32 -- ^ parameter 2+ -> Word32 -- ^ value -> Double -- ^ result density_2p d f p1 p2 x = unsafePerformIO $ do case d of@@ -200,10 +201,10 @@ -- | draw a sample from a three parameter distribution random_3p :: ThreeParamDist -- ^ distribution type -> Int -- ^ random seed- -> Int -- ^ parameter 1- -> Int -- ^ parameter 2- -> Int -- ^ parameter 3- -> Int -- ^ result+ -> Word32 -- ^ parameter 1+ -> Word32 -- ^ parameter 2+ -> Word32 -- ^ parameter 3+ -> Word32 -- ^ result random_3p d s p1 p2 p3 = unsafePerformIO $ alloca $ \r -> do check "random_3p" $ distribution_discrete_three_param (fromIntegral s) (fromei d) (fromIntegral p1) (fromIntegral p2) (fromIntegral p3) r@@ -213,10 +214,10 @@ -- | draw a sample from a three parameter distribution random_3p_s :: RNG -- ^ RNG -> ThreeParamDist -- ^ distribution type- -> Int -- ^ parameter 1- -> Int -- ^ parameter 2- -> Int -- ^ parameter 3- -> IO Int -- ^ result+ -> Word32 -- ^ parameter 1+ -> Word32 -- ^ parameter 2+ -> Word32 -- ^ parameter 3+ -> IO Word32 -- ^ result random_3p_s (RNG rng) d p1 p2 p3 = alloca $ \r -> withForeignPtr rng $ \rg -> do check "random_3p_s" $ distribution_discrete_three_param_s rg (fromei d) (fromIntegral p1) (fromIntegral p2) (fromIntegral p3) r@@ -226,11 +227,11 @@ -- | draw samples from a three parameter distribution random_3p_v :: ThreeParamDist -- ^ distribution type -> Int -- ^ random seed- -> Int -- ^ parameter 1- -> Int -- ^ parameter 2- -> Int -- ^ parameter 3+ -> Word32 -- ^ parameter 1+ -> Word32 -- ^ parameter 2+ -> Word32 -- ^ parameter 3 -> Int -- ^ number of samples- -> Vector Int -- ^ result+ -> Vector Word32 -- ^ result random_3p_v d s p1 p2 p3 l = unsafePerformIO $ do r <- createVector l app1 (distribution_discrete_three_param_v (fromIntegral s) (fromei d) (fromIntegral p1) (fromIntegral p2) (fromIntegral p3)) vec r "random_3p_v"@@ -239,10 +240,10 @@ -- | probability of a variate take a value outside the argument density_3p :: ThreeParamDist -- ^ density type -> DistFunc -- ^ distribution function type- -> Int -- ^ parameter 1- -> Int -- ^ parameter 2- -> Int -- ^ parameter 3- -> Int -- ^ value+ -> Word32 -- ^ parameter 1+ -> Word32 -- ^ parameter 2+ -> Word32 -- ^ parameter 3+ -> Word32 -- ^ value -> Double -- ^ result density_3p d f p1 p2 p3 x = unsafePerformIO $ do case d of@@ -261,30 +262,30 @@ -- | draw a sample from a multi-parameter distribution random_mp :: MultiParamDist -- ^ distribution type -> Int -- ^ random seed- -> Int -- ^ trials+ -> Word32 -- ^ trials -> Vector Double -- ^ parameters- -> Vector Int -- ^ result+ -> Vector Word32 -- ^ result random_mp d s t p = unsafePerformIO $ do r <- createVector $ dim p app2 (distribution_discrete_multi_param (fromIntegral s) (fromei d) (fromIntegral t)) vec p vec r "random_mp"- return $ mapVector (\x -> (fromIntegral x) :: Int) r+ return $ mapVector (\x -> (fromIntegral x) :: Word32) r -- | draw a sample from a multi-parameter distribution random_mp_s :: RNG -- ^ RNG -> MultiParamDist -- ^ distribution type- -> Int -- ^ trials+ -> Word32 -- ^ trials -> Vector Double -- ^ parameters- -> IO (Vector Int) -- ^ result+ -> IO (Vector Word32) -- ^ result random_mp_s (RNG rng) d t p = withForeignPtr rng $ \rg -> do r <- createVector $ dim p app2 (distribution_discrete_multi_param_s rg (fromei d) (fromIntegral t)) vec p vec r "random_mp_s"- return $ mapVector (\x -> (fromIntegral x) :: Int) r+ return $ mapVector (\x -> (fromIntegral x) :: Word32) r -- | probability of a variate take a value outside the argument density_mp :: MultiParamDist -- ^ density type -> DistFunc -- ^ distribution function type -> Vector Double -- ^ parameters- -> Vector Int -- ^ values+ -> Vector Word32 -- ^ values -> Double -- ^ result density_mp d f p q = unsafePerformIO $ do case d of