Created
July 27, 2012 11:07
-
-
Save einblicker/3187433 to your computer and use it in GitHub Desktop.
MCMCっぽいやつ
This file contains hidden or 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
(* 何かがおかしい。要検証。 *) | |
module MCMC = | |
let random = new Random() | |
let select x = x + (random.NextDouble() - 0.5) * 10.0 | |
let prob x = 1.0 / (1.0 + System.Math.Exp(-x)) | |
let nextStatus x = | |
let xt = select x | |
let p = prob xt / prob x | |
let q = random.NextDouble() | |
if p >= q then xt else x | |
let rec markovChain x = | |
seq { | |
yield x | |
yield! markovChain (nextStatus x) } | |
let randomSeq = markovChain 0.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment