diff options
| author | Scott Lawrence <scott+git@ineffectivetheory.com> | 2024-06-22 21:59:53 -0700 |
|---|---|---|
| committer | Scott Lawrence <scott+git@ineffectivetheory.com> | 2024-06-22 21:59:53 -0700 |
| commit | fe6ca0140228bc45da14857566af86f72140f38c (patch) | |
| tree | 8c68f8b8c561869c62ba5a92b8a39df906bd2e8a /src/MonteCarlo.jl | |
| parent | cd972df86d691f9e514fca74651f12dae87b24f8 (diff) | |
| download | vatic-main.tar.gz vatic-main.tar.bz2 vatic-main.zip | |
Diffstat (limited to 'src/MonteCarlo.jl')
| -rw-r--r-- | src/MonteCarlo.jl | 44 |
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 |
