flat-mcmc

Painless, efficient, general-purpose sampling from continuous distributions.
Log | Files | Refs | README | LICENSE

commit 1e9cca1c905c6c79fa0a469768d1ecd8c6455419
parent 96aa8b5c3d168c1f7b615883afc39ef5f630e132
Author: Jared Tobin <jared@jtobin.ca>
Date:   Fri,  2 Dec 2016 10:42:45 +1300

Assorted tweaks.

Diffstat:
Mflat-mcmc.cabal | 2+-
Mlib/Numeric/MCMC/Flat.hs | 2+-
Msrc/Main.hs | 5+++--
Mtest/BNN.hs | 5+++--
Mtest/Rosenbrock.hs | 5+++--
5 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/flat-mcmc.cabal b/flat-mcmc.cabal @@ -1,5 +1,5 @@ name: flat-mcmc -version: 1.4.0 +version: 1.4.1 synopsis: Painless general-purpose sampling. homepage: https://github.com/jtobin/flat-mcmc license: MIT diff --git a/lib/Numeric/MCMC/Flat.hs b/lib/Numeric/MCMC/Flat.hs @@ -141,7 +141,7 @@ execute target e0 e1 n = do zcs <- replicateM n uniform js <- U.replicateM n (uniformR (1, n)) - let granularity = truncate (fromIntegral n / 2) + let granularity = n `div` 2 w0 k = e0 `V.unsafeIndex` pred k w1 k ks = e1 `V.unsafeIndex` pred (ks `U.unsafeIndex` pred k) diff --git a/src/Main.hs b/src/Main.hs @@ -3,11 +3,12 @@ module Main where import Numeric.MCMC.Flat -import qualified Data.Vector.Unboxed as U (toList) +import qualified Data.Vector.Unboxed as U (unsafeIndex) bnn :: Particle -> Double bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where - [x0, x1] = U.toList xs + x0 = U.unsafeIndex xs 0 + x1 = U.unsafeIndex xs 1 origin :: Ensemble origin = ensemble [ diff --git a/test/BNN.hs b/test/BNN.hs @@ -3,11 +3,12 @@ module Main where import Numeric.MCMC.Flat -import qualified Data.Vector.Unboxed as U (toList) +import qualified Data.Vector.Unboxed as U (unsafeIndex) bnn :: Particle -> Double bnn xs = -0.5 * (x0 ^ 2 * x1 ^ 2 + x0 ^ 2 + x1 ^ 2 - 8 * x0 - 8 * x1) where - [x0, x1] = U.toList xs + x0 = U.unsafeIndex xs 0 + x1 = U.unsafeIndex xs 1 origin :: Ensemble origin = ensemble [ diff --git a/test/Rosenbrock.hs b/test/Rosenbrock.hs @@ -3,11 +3,12 @@ module Main where import Numeric.MCMC.Flat -import qualified Data.Vector.Unboxed as U (toList) +import qualified Data.Vector.Unboxed as U (unsafeIndex) rosenbrock :: Particle -> Double rosenbrock xs = negate (5 *(x1 - x0 ^ 2) ^ 2 + 0.05 * (1 - x0) ^ 2) where - [x0, x1] = U.toList xs + x0 = U.unsafeIndex xs 0 + x1 = U.unsafeIndex xs 1 origin :: Ensemble origin = ensemble [