Open ParadaCarleton opened 3 years ago
Demo algorithm 3:
n = 6
Z = 1:n
p = rand(n-2)
p /= sum(p)
p = [0; p; 0]
z = 2
d = 1
zs = [z]
t = 0.0
ts = [t]
iterations = 10000
for iter in 1:iterations
t += randexp()
if p[z+d] > p[z] || rand() < p[z+d]/p[z]
z += d
else
d *= -1
end
push!(zs, z)
push!(ts, t)
end
push!(ts, t[end]+randexp())
using StatsBase
T = ts[end]
Δts = diff(ts)
p̂ = zero(p)
for (Δt, z) in zip(Δts, zs)
p̂[z] += Δt/T
end
[p p̂]
@SebaGraz
@mschauer Did this end up getting done? Someone on the Slack is looking for discrete mixed/continuous sampling and I want to know whether I should point them at this.
No, we are working on it. Though we have an academic interest here: so while we can't offer an implementation ready to use we are looking for interesting use cases to try out.
Sampling from discrete variables, as shown here.