import System.Random import Text.Printf select :: (Double, Double) -> IO (Double, Double) select (x, y) = do dx <- getStdRandom $ randomR (-5,5) dy <- getStdRandom $ randomR (-5,5) return (x+dx, y+dy) prob :: (Double, Double) -> Double prob (x, y) = 1/(2*pi) * exp(-(x*x+y*y)/2) nextStatus :: (Double, Double) -> IO (Double, Double) nextStatus (x, y) = do (xt, yt) <- select(x, y) let p = min 1 (prob
![MCMCで二次元正規分布に従う乱数を生成する](https://cdn-ak-scissors.b.st-hatena.com/image/square/8808e05461fa28597076c026a45f6b41ac1ab5d8/height=288;version=1;width=512/https%3A%2F%2Fblogger.googleusercontent.com%2Fimg%2Fb%2FR29vZ2xl%2FAVvXsEjHMMy4gNfAMEVaY94aJ9t3yS4xuG_BFTdTgAhKkR2i35UCtc2vkKGpy7GInDynf2oks04kLEzTmjHdzr6IjxwdoIr7YzV5yitoLrySbdmv7Z6cayvVmMlkJdsHNikUdeUNsQ3orVNtZBU%2Fw1200-h630-p-k-no-nu%2F56957509_ca44108bd0.jpg)