Filters¶
Module containing filter classes to be used with pengu-track detectors and models.
-
class
PenguTrack.Filters.
AdaptedKalmanFilter
(model, evolution_variance, measurement_variance, **kwargs)[source]¶ -
predict
(u=None, i=None)[source]¶ Function to get predictions from the corresponding model. Handles time-stamps and control-vectors.
- Parameters
u (array_like, optional) – Recent control-vector.
i (int) – Recent/corresponding time-stamp
- Returns
u (array_like) – Recent control-vector.
i (int) – Recent/corresponding time-stamp.
-
update
(z=None, i=None)[source]¶ Function to get updates to the corresponding model. Handles time-stamps and measurement-vectors.
- Parameters
z (PenguTrack.Measurement, optional) – Recent measurement.
i (int) – Recent/corresponding time-stamp
- Returns
z (PenguTrack.Measurement) – Recent measurement.
i (int) – Recent/corresponding time-stamp.
-
-
class
PenguTrack.Filters.
AdvancedKalmanFilter
(*args, **kwargs)[source]¶ This Class describes a advanced, self tuning version of the kalman-filter in the pengu-track package. It calculates actual believed values from predictions and measurements.
- Variables
Model (PenguTrack.model object) – A physical model to gain predictions from data.
Lag (int) – The number of state-vectors, which are taken into acount for the self-tuning algorithm.
Measurement_Distribution (scipy.stats.distributions object) – The distribution which describes measurement uncertainty.
State_Distribution (scipy.stats.distributions object) – The distribution which describes state vector fluctuations.
X (dict) – The time series of believes calculated for this filter. The keys equal the time stamp.
X_error (dict) – The time series of errors on the corresponding believes. The keys equal the time stamp.
Predicted_X (dict) – The time series of predictions made from the associated data. The keys equal the time stamp.
Predicted_X_error (dict) – The time series of estimated prediction errors. The keys equal the time stamp.
Measurements (dict) – The time series of measurements assigned to this filter. The keys equal the time stamp.
Controls (dict) – The time series of control-vectors assigned to this filter. The keys equal the time stamp.
A (np.asarray) – State-Transition-Matrix, describing the evolution of the state without fluctuation. Received from the physical Model.
B (np.asarray) – State-Control-Matrix, describing the influence of external-control on the states. Received from the physical Model.
C (np.asarray) – Measurement-Matrix , describing the projection of the measurement-vector from the state-vector. Received from the physical Model.
G (np.asarray) – Evolution-Matrix, describing the evolution of state vectors by fluctuations from the state-distribution. Received from the physical Model.
Q (np.asarray) – Covariance matrix (time-evolving) for the state-distribution.
Q_0 (np.asarray) – Covariance matrix (initial state) for the state-distribution.
R (np.asarray) – Covariance matrix (time-evolving) for the measurement-distribution.
R_0 (np.asarray) – Covariance matrix (initial state) for the measurement-distribution.
P_0 (np.asarray) – Covariance matrix (initial state) for the believe-distribution.
-
update
(*args, **kwargs)[source]¶ Function to get updates to the corresponding model. Handles time-stamps and measurement-vectors.
- Parameters
z (PenguTrack.Measurement, optional) – Recent measurement.
i (int) – Recent/corresponding time-stamp
- Returns
z (PenguTrack.Measurement) – Recent measurement.
i (int) – Recent/corresponding time-stamp.
-
class
PenguTrack.Filters.
Filter
(model, no_dist=False, meas_dist=<MagicMock name='mock.stats.uniform()' id='140340807542376'>, state_dist=<MagicMock name='mock.stats.uniform()' id='140340807542376'>, prob_update=True, *args, **kwargs)[source]¶ This Class describes the abstract function of a filter in the pengu-track package. It is only meant for subclassing.
- Variables
Model (PenguTrack.model object) – A physical model to gain predictions from data.
Measurement_Distribution (scipy.stats.distributions object) – The distribution which describes measurement uncertainty.
State_Distribution (scipy.stats.distributions object) – The distribution which describes state vector fluctuations.
X (dict) – The time series of believes calculated for this filter. The keys equal the time stamp.
X_error (dict) – The time series of errors on the corresponding believes. The keys equal the time stamp.
Predicted_X (dict) – The time series of predictions made from the associated data. The keys equal the time stamp.
Predicted_X_error (dict) – The time series of estimated prediction errors. The keys equal the time stamp.
Measurements (dict) – The time series of measurements assigned to this filter. The keys equal the time stamp.
Controls (dict) – The time series of control-vectors assigned to this filter. The keys equal the time stamp.
-
downdate
(t=None)[source]¶ Function erases the time-step t from the Measurements and Believes.
- Parameters
t (int, optional) – Time-steps for which filtering should be erased.
-
downfilter
(t=None)[source]¶ Function erases the timestep t from the class dictionaries (Measurement, X, Preditcion)
- Parameters
t (int, optional) – Time-steps for which filtering should be erased.
-
filter
(u=None, z=None, i=None)[source]¶ Function to get predictions from the model and update the same timestep i.
- Parameters
u (array_like, optional) – Recent control-vector.
z (PenguTrack.Measurement, optional) – Recent measurement.
i (int) – Recent/corresponding time-stamp
- Returns
u (array_like, optional) – Recent control-vector.
z (PenguTrack.Measurement) – Recent measurement.
i (int) – Recent/corresponding time-stamp.
-
fit
(u, z)[source]¶ Function to auto-evaluate all measurements z with control-vectors u and starting probability p. It returns the believed values x, the corresponding probabilities p and the predictions x_tilde.
- Parameters
u (array_like) – List of control-vectors.
z (array_like) – List of measurement-vectors.
-
predict
(u=None, i=None)[source]¶ Function to get predictions from the corresponding model. Handles time-stamps and control-vectors.
- Parameters
u (array_like, optional) – Recent control-vector.
i (int) – Recent/corresponding time-stamp
- Returns
u (array_like) – Recent control-vector.
i (int) – Recent/corresponding time-stamp.
-
unpredict
(t=None)[source]¶ Function erases the time-step t from the Believes, Predictions and Controls.
- Parameters
t (int, optional) – Time-steps for which filtering should be erased.
-
update
(z=None, i=None)[source]¶ Function to get updates to the corresponding model. Handles time-stamps and measurement-vectors.
- Parameters
z (PenguTrack.Measurement, optional) – Recent measurement.
i (int) – Recent/corresponding time-stamp
- Returns
z (PenguTrack.Measurement) – Recent measurement.
i (int) – Recent/corresponding time-stamp.
-
class
PenguTrack.Filters.
HybridSolver
(*args, **kwargs)[source]¶ This Class describes a filter, which is capable of assigning measurements to tracks, which again are represented by sub-filters. The type of these can be specified, as well as a physical model for predictions. With these objects it is possible to assign possibilities to combinations of measurement and prediction.
- Variables
Model (PenguTrack.model object) – A physical model to gain predictions from data.
Filter_Class (PenguTrack.Filter object) – A Type of Filter from which all subfilters should be built.
Filters (dict) – Dictionary containing all sub-filters as PenguTrack.Filter objects.
Active_Filters (dict) – Dictionary containing all sub-filters, which are currently updated.
FilterThreshold (int) – Number of time steps, before a filter is set inactive.
LogProbabilityThreshold (float) – Threshold, under which log-probabilities are concerned negligible.
filter_args (list) – Filter-Type specific arguments from the Multi-Filter initialisation can be stored here.
filter_kwargs (dict) – Filter-Type specific keyword-arguments from the Multi-Filter initialisation can be stored here.
Measurement_Distribution (scipy.stats.distributions object) – The distribution which describes measurement uncertainty.
State_Distribution (scipy.stats.distributions object) – The distribution which describes state vector fluctuations.
X (dict) – The time series of believes calculated for this filter. The keys equal the time stamp.
X_error (dict) – The time series of errors on the corresponding believes. The keys equal the time stamp.
Predicted_X (dict) – The time series of predictions made from the associated data. The keys equal the time stamp.
Predicted_X_error (dict) – The time series of estimated prediction errors. The keys equal the time stamp.
Measurements (dict) – The time series of measurements assigned to this filter. The keys equal the time stamp.
Controls (dict) – The time series of control-vectors assigned to this filter. The keys equal the time stamp.
-
class
PenguTrack.Filters.
InformationFilter
(model, evolution_variance, measurement_variance, **kwargs)[source]¶ This Class describes a kalman-filter in the pengu-track package. It calculates actual believed values from predictions and measurements.
- Variables
Model (PenguTrack.model object) – A physical model to gain predictions from data.
Measurement_Distribution (scipy.stats.distributions object) – The distribution which describes measurement uncertainty.
State_Distribution (scipy.stats.distributions object) – The distribution which describes state vector fluctuations.
X (dict) – The time series of believes calculated for this filter. The keys equal the time stamp.
X_error (dict) – The time series of errors on the corresponding believes. The keys equal the time stamp.
Predicted_X (dict) – The time series of predictions made from the associated data. The keys equal the time stamp.
Predicted_X_error (dict) – The time series of estimated prediction errors. The keys equal the time stamp.
Measurements (dict) – The time series of measurements assigned to this filter. The keys equal the time stamp.
Controls (dict) – The time series of control-vectors assigned to this filter. The keys equal the time stamp.
A (np.asarray) – State-Transition-Matrix, describing the evolution of the state without fluctuation. Received from the physical Model.
B (np.asarray) – State-Control-Matrix, describing the influence of external-control on the states. Received from the physical Model.
C (np.asarray) – Measurement-Matrix , describing the projection of the measurement-vector from the state-vector. Received from the physical Model.
G (np.asarray) – Evolution-Matrix, describing the evolution of state vectors by fluctuations from the state-distribution. Received from the physical Model.
Q (np.asarray) – Covariance matrix (time-evolving) for the state-distribution.
Q_0 (np.asarray) – Covariance matrix (initial state) for the state-distribution.
R (np.asarray) – Covariance matrix (time-evolving) for the measurement-distribution.
R_0 (np.asarray) – Covariance matrix (initial state) for the measurement-distribution.
P_0 (np.asarray) – Covariance matrix (initial state) for the believe-distribution.
-
predict
(u=None, i=None)[source]¶ Function to get predictions from the corresponding model. Handles time-stamps and control-vectors.
- Parameters
u (array_like, optional) – Recent control-vector.
i (int) – Recent/corresponding time-stamp
- Returns
u (array_like) – Recent control-vector.
i (int) – Recent/corresponding time-stamp.
-
update
(z=None, i=None)[source]¶ Function to get updates to the corresponding model. Handles time-stamps and measurement-vectors.
- Parameters
z (PenguTrack.Measurement, optional) – Recent measurement.
i (int) – Recent/corresponding time-stamp
- Returns
z (PenguTrack.Measurement) – Recent measurement.
i (int) – Recent/corresponding time-stamp.
-
class
PenguTrack.Filters.
KalmanBaseFilter
(model, evolution_variance, measurement_variance, **kwargs)[source]¶ This Class describes a kalman-filter in the pengu-track package. It calculates actual believed values from predictions and measurements.
- Variables
Model (PenguTrack.model object) – A physical model to gain predictions from data.
Measurement_Distribution (scipy.stats.distributions object) – The distribution which describes measurement uncertainty.
State_Distribution (scipy.stats.distributions object) – The distribution which describes state vector fluctuations.
X (dict) – The time series of believes calculated for this filter. The keys equal the time stamp.
X_error (dict) – The time series of errors on the corresponding believes. The keys equal the time stamp.
Predicted_X (dict) – The time series of predictions made from the associated data. The keys equal the time stamp.
Predicted_X_error (dict) – The time series of estimated prediction errors. The keys equal the time stamp.
Measurements (dict) – The time series of measurements assigned to this filter. The keys equal the time stamp.
Controls (dict) – The time series of control-vectors assigned to this filter. The keys equal the time stamp.
A (np.asarray) – State-Transition-Matrix, describing the evolution of the state without fluctuation. Received from the physical Model.
B (np.asarray) – State-Control-Matrix, describing the influence of external-control on the states. Received from the physical Model.
C (np.asarray) – Measurement-Matrix , describing the projection of the measurement-vector from the state-vector. Received from the physical Model.
G (np.asarray) – Evolution-Matrix, describing the evolution of state vectors by fluctuations from the state-distribution. Received from the physical Model.
Q (np.asarray) – Covariance matrix (time-evolving) for the state-distribution.
Q_0 (np.asarray) – Covariance matrix (initial state) for the state-distribution.
R (np.asarray) – Covariance matrix (time-evolving) for the measurement-distribution.
R_0 (np.asarray) – Covariance matrix (initial state) for the measurement-distribution.
P_0 (np.asarray) – Covariance matrix (initial state) for the believe-distribution.
-
class
PenguTrack.Filters.
KalmanFilter
(model, evolution_variance, measurement_variance, **kwargs)[source]¶ -
predict
(u=None, i=None)[source]¶ Function to get predictions from the corresponding model. Handles time-stamps and control-vectors.
- Parameters
u (array_like, optional) – Recent control-vector.
i (int) – Recent/corresponding time-stamp
- Returns
u (array_like) – Recent control-vector.
i (int) – Recent/corresponding time-stamp.
-
update
(z=None, i=None)[source]¶ Function to get updates to the corresponding model. Handles time-stamps and measurement-vectors.
- Parameters
z (PenguTrack.Measurement, optional) – Recent measurement.
i (int) – Recent/corresponding time-stamp
- Returns
z (PenguTrack.Measurement) – Recent measurement.
i (int) – Recent/corresponding time-stamp.
-
-
class
PenguTrack.Filters.
MultiFilter
(_filter, model, *args, **kwargs)[source]¶ This Class describes a filter, which is capable of assigning measurements to tracks, which again are represented by sub-filters. The type of these can be specified, as well as a physical model for predictions. With these objects it is possible to assign possibilities to combinations of measurement and prediction.
- Variables
Model (PenguTrack.model object) – A physical model to gain predictions from data.
Filter_Class (PenguTrack.Filter object) – A Type of Filter from which all subfilters should be built.
Filters (dict) – Dictionary containing all sub-filters as PenguTrack.Filter objects.
Active_Filters (dict) – Dictionary containing all sub-filters, which are currently updated.
FilterThreshold (int) – Number of time steps, before a filter is set inactive.
LogProbabilityThreshold (float) – Threshold, under which log-probabilities are concerned negligible.
filter_args (list) – Filter-Type specific arguments from the Multi-Filter initialisation can be stored here.
filter_kwargs (dict) – Filter-Type specific keyword-arguments from the Multi-Filter initialisation can be stored here.
Measurement_Distribution (scipy.stats.distributions object) – The distribution which describes measurement uncertainty.
State_Distribution (scipy.stats.distributions object) – The distribution which describes state vector fluctuations.
X (dict) – The time series of believes calculated for this filter. The keys equal the time stamp.
X_error (dict) – The time series of errors on the corresponding believes. The keys equal the time stamp.
Predicted_X (dict) – The time series of predictions made from the associated data. The keys equal the time stamp.
Predicted_X_error (dict) – The time series of estimated prediction errors. The keys equal the time stamp.
Measurements (dict) – The time series of measurements assigned to this filter. The keys equal the time stamp.
Controls (dict) – The time series of control-vectors assigned to this filter. The keys equal the time stamp.
-
downdate
(t=None)[source]¶ Function erases the time-step t from the Measurements and Believes.
- Parameters
t (int, optional) – Time-steps for which filtering should be erased.
-
downfilter
(t=None)[source]¶ Function erases the timestep t from the class dictionaries (Measurement, X, Preditcion)
- Parameters
t (int, optional) – Time-steps for which filtering should be erased.
-
fit
(u, z)[source]¶ Function to auto-evaluate all measurements z with control-vectors u and starting probability p. It returns the believed values x, the corresponding probabilities p and the predictions x_tilde.
- Parameters
u (array_like) – List of control-vectors.
z (list of PenguTrack.Measurement objects) – Recent measurements.
-
initial_update
(z, i)[source]¶ Function to get updates to the corresponding model in the first time step. Handles time-stamps and measurement-vectors. This function also handles the assignment of all incoming measurements to the active sub-filters.
- Parameters
z (list of PenguTrack.Measurement objects) – Recent measurements.
i (int) – Recent/corresponding time-stamp.
- Returns
z (list of PenguTrack.Measurement objects) – Recent measurements.
i (int) – Recent/corresponding time-stamp.
-
log_prob
(**kwargs)[source]¶ Function to calculate the probability measure by predictions, measurements and corresponding distributions.
- Parameters
keys (list of int, optional) – Time-steps for which probability should be calculated.
- Returns
prob (float) – Probability of measurements at the given time-keys.
-
predict
(u=None, i=None)[source]¶ Function to get predictions from the corresponding sub-filter models. Handles time-stamps and control-vectors.
- Parameters
u (array_like, optional) – Recent control-vector.
i (int) – Recent/corresponding time-stamp
- Returns
u (array_like) – Recent control-vector.
i (int) – Recent/corresponding time-stamp.
-
unpredict
(t=None)[source]¶ Function erases the time-step t from the Believes, Predictions and Controls.
- Parameters
t (int, optional) – Time-steps for which filtering should be erased.
-
update
(z=None, i=None, big_jumps=False, verbose=False)[source]¶ Function to get updates to the corresponding model. Handles time-stamps and measurement-vectors. This function also handles the assignment of all incoming measurements to the active sub-filters.
- Parameters
z (list of PenguTrack.Measurement objects) – Recent measurements.
i (int) – Recent/corresponding time-stamp.
- Returns
z (list of PenguTrack.Measurement objects) – Recent measurements.
i (int) – Recent/corresponding time-stamp.
-
class
PenguTrack.Filters.
NetworkTracker
(*args, **kwargs)[source]¶ This Class describes a filter, which is capable of assigning measurements to tracks, which again are represented by sub-filters. The type of these can be specified, as well as a physical model for predictions. With these objects it is possible to assign possibilities to combinations of measurement and prediction.
- Variables
Model (PenguTrack.model object) – A physical model to gain predictions from data.
Filter_Class (PenguTrack.Filter object) – A Type of Filter from which all subfilters should be built.
Filters (dict) – Dictionary containing all sub-filters as PenguTrack.Filter objects.
Active_Filters (dict) – Dictionary containing all sub-filters, which are currently updated.
FilterThreshold (int) – Number of time steps, before a filter is set inactive.
LogProbabilityThreshold (float) – Threshold, under which log-probabilities are concerned negligible.
filter_args (list) – Filter-Type specific arguments from the Multi-Filter initialisation can be stored here.
filter_kwargs (dict) – Filter-Type specific keyword-arguments from the Multi-Filter initialisation can be stored here.
Measurement_Distribution (scipy.stats.distributions object) – The distribution which describes measurement uncertainty.
State_Distribution (scipy.stats.distributions object) – The distribution which describes state vector fluctuations.
X (dict) – The time series of believes calculated for this filter. The keys equal the time stamp.
X_error (dict) – The time series of errors on the corresponding believes. The keys equal the time stamp.
Predicted_X (dict) – The time series of predictions made from the associated data. The keys equal the time stamp.
Predicted_X_error (dict) – The time series of estimated prediction errors. The keys equal the time stamp.
Measurements (dict) – The time series of measurements assigned to this filter. The keys equal the time stamp.
Controls (dict) – The time series of control-vectors assigned to this filter. The keys equal the time stamp.
Order (int) – The order of network assignments. The higher, the more costy and precise the assignment will be.
-
class
PenguTrack.Filters.
ParticleFilter
(model, n=100, meas_dist=<MagicMock name='mock.stats.uniform()' id='140340807542376'>, state_dist=<MagicMock name='mock.stats.uniform()' id='140340807542376'>)[source]¶ This Class describes a particle-filter in the pengu-track package. It calculates actual believed values from predictions and measurements.
- Variables
Model (PenguTrack.model object) – A physical model to gain predictions from data.
N (int) – The number of particles.
Particles (dict) – The current particle state-vectors.
Weights (dict) – Weights for every particle. Calculated from probability.
Measurement_Distribution (scipy.stats.distributions object) – The distribution which describes measurement uncertainty.
State_Distribution (scipy.stats.distributions object) – The distribution which describes state vector fluctuations.
X (dict) – The time series of believes calculated for this filter. The keys equal the time stamp.
X_error (dict) – The time series of errors on the corresponding believes. The keys equal the time stamp.
Predicted_X (dict) – The time series of predictions made from the associated data. The keys equal the time stamp.
Predicted_X_error (dict) – The time series of estimated prediction errors. The keys equal the time stamp.
Measurements (dict) – The time series of measurements assigned to this filter. The keys equal the time stamp.
Controls (dict) – The time series of control-vectors assigned to this filter. The keys equal the time stamp.
-
predict
(u=None, i=None)[source]¶ Function to get predictions from the corresponding model. Handles time-stamps and control-vectors.
- Parameters
u (array_like, optional) – Recent control-vector.
i (int) – Recent/corresponding time-stamp
- Returns
u (array_like) – Recent control-vector.
i (int) – Recent/corresponding time-stamp.
-
update
(z=None, i=None)[source]¶ Function to get updates to the corresponding model. Handles time-stamps and measurement-vectors.
- Parameters
z (PenguTrack.Measurement, optional) – Recent measurement.
i (int) – Recent/corresponding time-stamp
- Returns
z (PenguTrack.Measurement) – Recent measurement.
i (int) – Recent/corresponding time-stamp.