This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
logRosenbrockDensity :: [Double] -> Double | |
logRosenbrockDensity [x0, x1] = (-1)*(100*(x1 - (x0^2))^2 + (1 - x0)^2) / 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Numeric.AD | |
gTarget :: [Double] -> [Double] | |
gTarget = grad target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS_GHC -Wall #-} | |
{-# LANGUAGE TemplateHaskell #-} | |
import Data.List | |
import Data.Hashable (Hashable) | |
import Data.HashMap.Strict hiding (filter) | |
import Control.Monad | |
import Test.QuickCheck | |
import Test.QuickCheck.All | |
import Criterion.Main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== prop_i0ResultElementsAreInBoth from ui.hs:64 === | |
+++ OK, passed 1000 tests. | |
=== prop_i1ResultElementsAreInBoth from ui.hs:68 === | |
+++ OK, passed 1000 tests. | |
=== prop_i2ResultElementsAreInBoth from ui.hs:72 === | |
+++ OK, passed 1000 tests. | |
=== prop_u0ResultElementsInAtLeastOne from ui.hs:77 === |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# OPTIONS_GHC -Wall #-} | |
import Data.Function | |
import Data.List | |
main :: IO () | |
main = print $ minimumBy (compare `on` sumDiffs) portfolios | |
-- Data ------------------------------------------------------------------------ |
OlderNewer