aboutsummaryrefslogtreecommitdiffstats
path: root/src/MonteCarlo.jl
blob: 6c7251f47503397a2cf80a20755054b82a9ba558 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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