Beispiel #1
0
from __future__ import division, print_function

from matplotlib import pyplot as plt
import numpy as np
# import seaborn as sb

import particles
from particles import distributions as dists
from particles import state_space_models

# set up models, simulate and save data
T = 100
mu0 = 0.
phi0 = 0.9
sigma0 = .5  # true parameters
ssm = state_space_models.DiscreteCox(mu=mu0, phi=phi0, sigma=sigma0)
true_states, data = ssm.simulate(T)
fkmod = state_space_models.Bootstrap(ssm=ssm, data=data)

# run particle filter, compute trajectories
N = 100
pf = particles.SMC(fk=fkmod, N=N, store_history=True)
pf.run()
Bs = pf.hist.compute_trajectories()

# PLOT
# ====
# sb.set_palette("dark")
plt.style.use('ggplot')
savefigs = True  # False if you don't want to save plots as pdfs
Beispiel #2
0
from __future__ import division, print_function

from matplotlib import pyplot as plt
import numpy as np
# import seaborn as sb

import particles
from particles import distributions as dists
from particles import state_space_models as ssm

# set up models, simulate and save data
T = 100
mu0 = 0.
phi0 = 0.9
sigma0 = .5  # true parameters
my_ssm = ssm.DiscreteCox(mu=mu0, phi=phi0, sigma=sigma0)
true_states, data = my_ssm.simulate(T)
fkmod = ssm.Bootstrap(ssm=my_ssm, data=data)

# run particle filter, compute trajectories
N = 100
pf = particles.SMC(fk=fkmod, N=N, store_history=True)
pf.run()
pf.hist.compute_trajectories()

# PLOT
# ====
# sb.set_palette("dark")
plt.style.use('ggplot')
savefigs = False