aboutsummaryrefslogtreecommitdiffstats
path: root/src/MonteCarlo.jl
diff options
context:
space:
mode:
authorScott Lawrence <scott+git@ineffectivetheory.com>2024-06-22 21:59:53 -0700
committerScott Lawrence <scott+git@ineffectivetheory.com>2024-06-22 21:59:53 -0700
commitfe6ca0140228bc45da14857566af86f72140f38c (patch)
tree8c68f8b8c561869c62ba5a92b8a39df906bd2e8a /src/MonteCarlo.jl
parentcd972df86d691f9e514fca74651f12dae87b24f8 (diff)
downloadvatic-fe6ca0140228bc45da14857566af86f72140f38c.tar.gz
vatic-fe6ca0140228bc45da14857566af86f72140f38c.tar.bz2
vatic-fe6ca0140228bc45da14857566af86f72140f38c.zip
Progress toward MCMCHEADmain
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