flat-mcmc 1.0.1 → 1.1.1
raw patch · 4 files changed
+28/−26 lines, 4 filesdep ~basedep ~monad-pardep ~monad-par-extrasPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, monad-par, monad-par-extras, pipes
API changes (from Hackage documentation)
Files
- flat-mcmc.cabal +7/−7
- lib/Numeric/MCMC/Flat.hs +3/−3
- test/BNN.hs +9/−8
- test/Rosenbrock.hs +9/−8
flat-mcmc.cabal view
@@ -1,5 +1,5 @@ name: flat-mcmc-version: 1.0.1+version: 1.1.1 synopsis: Painless general-purpose sampling. homepage: http://jtobin.github.com/flat-mcmc license: MIT@@ -52,12 +52,12 @@ hs-source-dirs: lib exposed-modules: Numeric.MCMC.Flat build-depends:- base < 5+ base > 4 && < 6 , mcmc-types >= 1.0.1 && < 2- , monad-par- , monad-par-extras+ , monad-par >= 0.3.4.7 && < 1+ , monad-par-extras >= 0.3.3 && < 1 , mwc-probability >= 1.0.1 && < 2- , pipes >= 4 && < 5+ , pipes > 4 && < 5 , primitive , transformers , vector@@ -70,7 +70,7 @@ ghc-options: -rtsopts -threaded build-depends:- base < 5+ base , flat-mcmc , vector @@ -82,7 +82,7 @@ ghc-options: -rtsopts -threaded build-depends:- base < 5+ base , flat-mcmc , vector
lib/Numeric/MCMC/Flat.hs view
@@ -64,7 +64,7 @@ . V.map show $ chainPosition -type Particle = Vector Double+type Particle = U.Vector Double type Ensemble = Vector Particle @@ -73,13 +73,13 @@ transform z = 0.5 * (z + 1) ^ (2 :: Int) stretch :: Particle -> Particle -> Double -> Particle-stretch p0 p1 z = V.zipWith (+) (V.map (* z) p0) (V.map (* (1 - z)) p1)+stretch p0 p1 z = U.zipWith (+) (U.map (* z) p0) (U.map (* (1 - z)) p1) acceptProb :: Target Particle -> Particle -> Particle -> Double -> Double acceptProb target particle proposal z = lTarget target proposal - lTarget target particle- + log z * (fromIntegral (V.length particle) - 1)+ + log z * (fromIntegral (U.length particle) - 1) move :: Target Particle -> Particle -> Particle -> Double -> Double -> Particle move target p0 p1 z zc =
test/BNN.hs view
@@ -3,18 +3,19 @@ module Main where import Numeric.MCMC.Flat-import Data.Vector (Vector, toList, fromList)+import qualified Data.Vector.Unboxed as U (Vector, toList, fromList)+import qualified Data.Vector as V (fromList) -bnn :: Vector Double -> Double+bnn :: Particle -> Double bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where- [x0, x1] = toList xs+ [x0, x1] = U.toList xs ensemble :: Ensemble-ensemble = fromList [- fromList [negate 1.0, negate 1.0]- , fromList [negate 1.0, 1.0]- , fromList [1.0, negate 1.0]- , fromList [1.0, 1.0]+ensemble = V.fromList [+ U.fromList [negate 1.0, negate 1.0]+ , U.fromList [negate 1.0, 1.0]+ , U.fromList [1.0, negate 1.0]+ , U.fromList [1.0, 1.0] ] main :: IO ()
test/Rosenbrock.hs view
@@ -3,18 +3,19 @@ module Main where import Numeric.MCMC.Flat-import Data.Vector (Vector, toList, fromList)+import qualified Data.Vector.Unboxed as U (Vector, toList, fromList)+import qualified Data.Vector as V (fromList) -rosenbrock :: Vector Double -> Double+rosenbrock :: Particle -> Double rosenbrock xs = negate (5 *(x1 - x0 ^ 2) ^ 2 + 0.05 * (1 - x0) ^ 2) where- [x0, x1] = toList xs+ [x0, x1] = U.toList xs ensemble :: Ensemble-ensemble = fromList [- fromList [negate 1.0, negate 1.0]- , fromList [negate 1.0, 1.0]- , fromList [1.0, negate 1.0]- , fromList [1.0, 1.0]+ensemble = V.fromList [+ U.fromList [negate 1.0, negate 1.0]+ , U.fromList [negate 1.0, 1.0]+ , U.fromList [1.0, negate 1.0]+ , U.fromList [1.0, 1.0] ] main :: IO ()