Created
March 10, 2021 10:25
-
-
Save mschauer/fa68d1d5ddcf08a87525e8318e8ca195 to your computer and use it in GitHub Desktop.
Sketch BFFG markov chain
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
xnew = sample(A[x, :]) | |
struct TransitionKernel | |
A::Matrix | |
end | |
(kappa::TransitionKernel)(x) = kappa.A[x, :] | |
A = [0.5 0.5 0 | |
0 0.3 0.7 | |
1/3 1/3 1/3 | |
] | |
kappa = TransitionKernel(A) | |
x = 2 | |
kappa(x) == [0.0, 0.3,0.7] | |
function backward(kappatilde::TransitionKernel, h) | |
hout = kappatilde.A*h | |
message = (hout, h) | |
return message, hout | |
end | |
function forward(kappa::TransitionKernel, message, x) | |
A = kappa.A | |
hout, h = message | |
samplefrom = A[x, :] .* h | |
samplefrom ./ sum(samplefrom) | |
end | |
hT = [0, 0, 1] | |
message, hout = backward(kappatilde, hT) | |
... | |
... | |
x = sample(forward(kappa, message, x)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment