flat-mcmc

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

commit a38bbed1f53565f05dffc83dfada02a2ebe04e61
parent 79f72abe2b79991e79e7208f6ad28e45b5090aa7
Author: Jared Tobin <jared@jtobin.ca>
Date:   Sun,  3 Apr 2016 20:58:46 +0700

Estimate appropriate granularity.

Diffstat:
MREADME.md | 2+-
Mlib/Numeric/MCMC/Flat.hs | 7+++++--
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md @@ -40,7 +40,7 @@ ensemble = fromList [ ] main :: IO () -main = withSystemRandom . asGenIO $ mcmc 25000 ensemble rosenbrock +main = withSystemRandom . asGenIO $ mcmc 12500 ensemble rosenbrock ``` ![trace](http://jtobin.ca/flat-mcmc/img/Rosenbrock_AIE.png) diff --git a/lib/Numeric/MCMC/Flat.hs b/lib/Numeric/MCMC/Flat.hs @@ -80,13 +80,16 @@ execute target e0 e1 n = do zcs <- replicateM n uniform vjs <- replicateM n (uniformR (1, n)) - let js = U.fromList vjs + let granularity = truncate (fromIntegral n / 2) + + js = U.fromList vjs w0 k = e0 `V.unsafeIndex` pred k w1 k ks = e1 `V.unsafeIndex` pred (ks `U.unsafeIndex` pred k) + worker (k, z, zc) = move target (w0 k) (w1 k js) z zc result = runPar $ - parMapChunk 2 worker (zip3 [1..n] zs zcs) -- FIXME granularity option + parMapChunk granularity worker (zip3 [1..n] zs zcs) return $ V.fromList result