You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use particle filtering on an agent based model.
m = ParticleFilterModel{AgentBasedModel{Union{Grass, Sheep, Wolf},GridSpace{LightGraphs.SimpleGraphs.SimpleGraph{Int64},2,Int64},Agents.var"#by_union#9"{Bool,Bool},Nothing}}(f, g);
# We've already run the model to create some data
zs = convert(Array{Array{Float64, 1}, 1}, [[a, b] for (a, b) in zip(results.count_wolves, results.count_sheep)])
vs = [[a, a] for a in zeros(Float64, 501, 1)]
n = 5
fil = SIRParticleFilter(m, n)
d = Bernoulli(0.5)
Random.seed!(42)
# construct initial belief
b0 = ParticleCollection([
initialize_model(
n_sheep = 100 + sum(rand(d,10)),
n_wolves = 20 + sum(rand(d,10)),
dims = (25, 25),
regrowth_time = 30,
Δenergy_sheep = exp(log(5) + 1.0 * randn()),
Δenergy_wolf = exp(log(20) + 1.0 * randn()),
sheep_reproduce = exp(log(0.2) + 0.1 * randn()),
wolf_reproduce = exp(log(0.08) + 0.1 * randn())
) for i in 1:n])
df0 = init_model_dataframe(particle(b0,1), mdata)
for i in 1:n collect_model_data!(df0,particle(b0,i),mdata) end
pm = predict(m, b0, vs[1], MersenneTwister(42))
df1 = init_model_dataframe(pm[1], mdata)
for i in 1:n collect_model_data!(df1,pm[i],mdata) end
wm = reweight(m, b0, vs[1], pm, zs[1])
so when I resample I should see about 3/4 particles sampled from the particle with weight 0.00026809439279891365 and about 1/2 particles sampled from the particle with weight 0.00014350058766747782.
I can see resample(resampler, bp, rng) but
Where do I get a resampler from and
How do I convert an array to a WeightedParticleBelief
Apologies if this is obvious but I am very new to julia - thanks in advance :-)
The text was updated successfully, but these errors were encountered:
I am trying to use particle filtering on an agent based model.
I get weights of
so when I resample I should see about 3/4 particles sampled from the particle with weight 0.00026809439279891365 and about 1/2 particles sampled from the particle with weight
0.00014350058766747782
.I can see
resample(resampler, bp, rng)
butresampler
from andWeightedParticleBelief
Apologies if this is obvious but I am very new to julia - thanks in advance :-)
The text was updated successfully, but these errors were encountered: