Simulator¶
Simulator¶
This is the main class used to run the different algorithms using a user specified model class
-
class
pyparticleest.simulator.
Simulator
(model, u, y)¶ Class interfacing filters/smoothers to assisst in solving estimation problem
- Args:
- model: object of class describing problem type
- u (array-like): inputs, first dimension is the time index, the rest is specific to the particlar model class being used
- y (array-like): measurements, first dimension is the time index, the rest is specific to the particlar model class being used
-
get_filtered_estimates
()¶ - Returns type (est, w) (must first have called ‘simulate’)
- est: (T, N, D) array containing all particles
- w: (T,D) array containing all particle weights
T is the length of the dataset, N is the number of particles and D is the dimension of each particle
-
get_filtered_mean
()¶ Calculate mean of filtered estimates (must first have called ‘simulate’)
- Returns:
- (T, D) array
T is the length of the dataset, N is the number of particles and D is the dimension of each particle
-
get_smoothed_estimates
()¶ Return smoothed estimates (must first have called ‘simulate’)
- Returns:
- (T, N, D) array
T is the length of the dataset, N is the number of particles D is the dimension of each particle
-
get_smoothed_mean
()¶ Calculate mean of smoothed estimates (must first have called ‘simulate’)
- Returns:
- (T, D) array
T is the length of the dataset, N is the number of particles and D is the dimension of each particle
-
set_params
(params)¶ Set the parameters of the model (if any)
- Args:
- params (array-like): Model specific paremeters
-
simulate
(num_part, num_traj, filter='PF', filter_options=None, smoother='full', smoother_options=None, res=0.67, meas_first=False)¶ Solve the estimation problem
- Args:
- num_part (int): Number of particles used in the forward filter.
- num_traj (int): Number of backward trajectories generated by the smoother.
- filter (string): The filter algorithm to use
- smooter (string): The smoothing algorithm to use
- smoother_options (dict): algorithm specific smoother options
- res (float): resampling threshold for the forward filter
- meas_first (bool): Is the first measurement of the initial state (true) or after the first time update? (false)
- Supported filters:
- ‘pf’: regular particle filter
- ‘apf’: auxilliary particle filter
- Supported smoothers:
- ‘ancestor’: return forward trajectories from particle filtier (no extra smoothing step)
- ‘full’: Backward simulation evaluating all particle weights
- ‘rs’: Rejection sampling (with early stopping)
- Options:
- R: number of rejection sampling steps before falling back to ‘full’
- ‘rsas’: Rejection sampling with early stopping.
- Options:
- x1 (float): (default is 1.0)
- P1 (float): (default is 1.0)
- sv (float): (default is 1.0)
- sw (float): (default is 1.0)
- ratio (float): (default is 1.0)
- ‘mcmc’: Metropolis-Hastings FFBSi
- Options:
- R: number of iterations to run the Markov chain
- ‘mhips’: Metropolis-Hastings Improved Particle Smoother
- Options:
- R: number of passes of the dataset to run the algortithms
- ‘mhbp’: Metropolis-Hastings Backward Proposer
- Options:
- R: the number of iterations to run the Markov chain for each time step
Parameter Estimator¶
This is an extension of the Simulator class which allows parameter estimation
-
class
pyparticleest.paramest.paramest.
ParamEstimation
(model, u, y)¶ Extension of the Simulator class to iterative perform particle smoothing combined with a gradienst search algorithms for maximizing the likelihood of the parameter estimates
-
maximize
(param0, num_part, num_traj, max_iter=1000, tol=0.001, callback=None, callback_sim=None, meas_first=False, filter='pf', smoother='full', smoother_options=None)¶ Find the maximum likelihood estimate of the paremeters using an EM-algorihms combined with a gradient search algorithms
- Args:
- param0 (array-like): Initial parameter estimate
- num_part (int/array-like): Number of particle to use in the forward filter if array each iteration takes the next element from the array when setting up the filter
- num_traj (int/array-like): Number of smoothed trajectories to create if array each iteration takes the next element from the array when setting up the smoother
- max_iter (int): Max number of EM-iterations to perform
- tol (float): When the different in loglikelihood between two iterations is less that his value the algorithm is terminated
- callback (function): Callback after each EM-iteration with new estimate
- callback_sim (function): Callback after each simulation
- bounds (array-like): Hard bounds on parameter estimates
- meas_first (bool): If true, first measurement occurs before the first time update
- smoother (string): Which particle smoother to use
- smoother_options (dict): Extra options for the smoother
- analytic_gradient (bool): Use analytic gradient (requires that the model implements ParamEstInterface_GradientSearch)
-