Rosenbrock.hs (341B)
1 {-# OPTIONS_GHC -fno-warn-type-defaults #-} 2 3 module Main where 4 5 import Numeric.MCMC.Metropolis 6 7 rosenbrock :: [Double] -> Double 8 rosenbrock [x0, x1] = negate (5 *(x1 - x0 ^ 2) ^ 2 + 0.05 * (1 - x0) ^ 2) 9 10 main :: IO () 11 main = withSystemRandom . asGenIO $ \gen -> do 12 _ <- chain 50 1 [0, 0] rosenbrock gen 13 mcmc 50 1 [0, 0] rosenbrock gen 14