aboutsummaryrefslogtreecommitdiffstats
path: root/src/MonteCarlo.jl
diff options
context:
space:
mode:
Diffstat (limited to 'src/MonteCarlo.jl')
-rw-r--r--src/MonteCarlo.jl44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/MonteCarlo.jl b/src/MonteCarlo.jl
index 5d87834..6c7251f 100644
--- a/src/MonteCarlo.jl
+++ b/src/MonteCarlo.jl
@@ -1,6 +1,50 @@
module MonteCarlo
+abstract type Proposer end
+
+struct GaussianProposer
+ σ::Float64
+end
+
+function (prop::GaussianProposer)(x::Vector{Float64})
+ for i in length(x)
+ x += prop.σ * randn()
+ end
+end
+
+abstract type Distribution end
+
struct MarkovChain
+ dist::Distribution
+ prop!::Proposer
+ x::Vector{Float64}
+ logp::Float64
+ x′::Vector{Float64}
+end
+
+function step!(mc::MarkovChain)::Bool
+ x′ .= x
+ mc.prop!(x′)
+ logp′ = mc.dist(x′)
+ # TODO distribution
+end
+
+function calibrate!(mc::MarkovChain)
+ while true
+ for s in 1:100
+ acc += step!(mc)
+ end
+ if acc < 30
+ # TODO
+ elseif acc > 50
+ # TODO
+ else
+ break
+ end
+ end
+end
+
+struct HamiltonianMonteCarlo
end
end