{{ message }}

Instantly share code, notes, and snippets.

# Jared Tobinjtobin

Created Oct 10, 2012
Incorporating parallelism
View gist:3865601
 import Control.Monad.Par -- Using the Par monad logRosenbrockDensity :: [Double] -> Double logRosenbrockDensity [x0, x1] = runPar \$ do [a, b] <- sequence [new, new] fork \$ put a (-100*(x1 - (x0^2))^2 / 20) fork \$ put b (-0.05*(1-x0)^2) [a', b'] <- sequence [get a, get b] return \$ a' + b'
Created Oct 10, 2012
View gist:3865828
 logRosenbrockDensity :: [Double] -> Double logRosenbrockDensity [x0, x1] = (-1)*(100*(x1 - (x0^2))^2 + (1 - x0)^2) / 20
Created Oct 10, 2012
Simple benchmark
View gist:3865854
 \$ time ./Rosenbrock 500 > trace.dat # using an ensemble containing 200 particles (flat-mcmc) Rosenbrock density 20259 / 100000 (0.20259) proposals accepted real 0m0.428s user 0m0.367s sys 0m0.016s
Created Nov 7, 2012
Stochastic partial differential equation
View gist:4028961
 target :: [Double] -> Double target xs = go 0 0 xs where go t0 t1 [] = -0.5 * t0 / h - 0.5 * h * t1 go t0 t1 (u:us:uss) = go (t0 + (us - u)^2) (t1 + v (us + u)) uss h = 1 / fromIntegral (length xs) v x = (1 - x^2)^2
Created Nov 7, 2012
SPDE parallel run
View gist:4029005
 ./SPDE 1000000 1000 +RTS -N4 -qg > trace.dat MUT time 4723.78s (1620.24s elapsed) GC time 623.24s (596.64s elapsed) Total time 5347.02s (2216.89s elapsed)
Created Nov 7, 2012
SPDE sequential run
View gist:4029008
 ./SPDE 1000000 1000 > trace.dat MUT time 2769.65s (2770.68s elapsed) GC time 600.57s (599.46s elapsed) Total time 3370.22s (3370.13s elapsed)
Created Nov 12, 2012
View gist:4057105