Transition Models¶

class
stonesoup.models.transition.base.
TransitionModel
[source]¶ Bases:
stonesoup.models.base.Model
Transition Model base class

property
ndim
¶ Number of dimensions of model

abstract property
ndim_state
¶ Number of state dimensions

property
Linear¶

class
stonesoup.models.transition.linear.
LinearGaussianTransitionModel
[source]¶ Bases:
stonesoup.models.transition.base.TransitionModel
,stonesoup.models.base.LinearModel
,stonesoup.models.base.GaussianModel

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

abstract
covar
()¶ Model covariance

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

abstract
matrix
()¶ Model matrix

property
ndim
¶ Number of dimensions of model

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

property

class
stonesoup.models.transition.linear.
CombinedLinearGaussianTransitionModel
(model_list)[source]¶ Bases:
stonesoup.models.base.LinearModel
,stonesoup.models.transition.base._CombinedGaussianTransitionModel
Combine multiple models into a single model by stacking them.
The assumption is that all models are Linear and Gaussian. Time Variant, and Time Invariant models can be combined together. If any of the models are time variant the keyword argument “time_interval” must be supplied to all methods
 Parameters
model_list (
Sequence[GaussianModel]
) – List of Transition Models.

matrix
(**kwargs)[source]¶ Model matrix \(F\)
 Returns
 Return type
numpy.ndarray
of shape (ndim_state
,ndim_state
)

covar
(**kwargs)¶ Returns the transition model noise covariance matrix.
 Returns
The process noise covariance.
 Return type
stonesoup.types.state.CovarianceMatrix
of shape (ndim_state
,ndim_state
)

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

model_list
: Sequence[stonesoup.models.base.GaussianModel]¶ List of Transition Models.

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of combined model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
LinearGaussianTimeInvariantTransitionModel
(transition_matrix, covariance_matrix, control_matrix=None)[source]¶ Bases:
stonesoup.models.transition.linear.LinearGaussianTransitionModel
,stonesoup.models.base.TimeInvariantModel
Generic Linear Gaussian Time Invariant Transition Model.
 Parameters
transition_matrix (
numpy.ndarray
) – Transition matrix \(\mathbf{F}\).covariance_matrix (
CovarianceMatrix
) – Transition noise covariance matrix \(\mathbf{Q}\).control_matrix (
numpy.ndarray
, optional) – Control matrix \(\mathbf{B}\).

transition_matrix
: numpy.ndarray¶ Transition matrix \(\mathbf{F}\).

control_matrix
: numpy.ndarray¶ Control matrix \(\mathbf{B}\).

covariance_matrix
: stonesoup.types.array.CovarianceMatrix¶ Transition noise covariance matrix \(\mathbf{Q}\).

matrix
(**kwargs)[source]¶ Model matrix \(F\)
 Returns
The model matrix evaluated given the provided time interval.
 Return type
numpy.ndarray
of shape (ndim_state
,ndim_state
)

covar
(**kwargs)[source]¶ Returns the transition model noise covariance matrix.
 Returns
The process noise covariance.
 Return type
stonesoup.types.state.CovarianceMatrix
of shape (ndim_state
,ndim_state
)

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
ConstantNthDerivative
(constant_derivative, noise_diff_coeff)[source]¶ Bases:
stonesoup.models.transition.linear.LinearGaussianTransitionModel
,stonesoup.models.base.TimeVariantModel
Discrete model based on the Nth derivative with respect to time being constant, to set derivative use keyword argument
constant_derivative
The model is described by the following SDEs:
\begin{eqnarray} dx^{(N1)} & = & x^{(N)} dt &  {(N1)th \ derivative \ on \ Xaxis (m)} \\ dx^{(N)} & = & q\cdot dW_t,\ W_t \sim \mathcal{N}(0,q^2) &  \ Nth\ derivative\ on\ Xaxis (m/s^{N}) \end{eqnarray}It is hard to represent the matrix form of these due to the fact that they vary with N, examples for N=1 and N=2 can be found in the
ConstantVelocity
andConstantAcceleration
models respectively. To aid visualisation of \(F_t\) the elements are calculated as the terms of the taylor expansion of each state variable. Parameters
constant_derivative (
int
) – The order of the derivative with respect to time to be kept constant, eg if 2 identical to constant accelerationnoise_diff_coeff (
float
) – The Nth derivative noise diffusion coefficient (Variance) \(q\)

constant_derivative
: int¶ The order of the derivative with respect to time to be kept constant, eg if 2 identical to constant acceleration

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

property
ndim
¶ Number of dimensions of model

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
RandomWalk
(noise_diff_coeff)[source]¶ Bases:
stonesoup.models.transition.linear.ConstantNthDerivative
This is a class implementation of a discrete, timevariant 1D LinearGaussian Random Walk Transition Model.
The target is assumed to be (almost) stationary, where target velocity is modelled as white noise.
 Parameters
noise_diff_coeff (
float
) – The position noise diffusion coefficient \(q\)

property
constant_derivative
¶ For random walk, this is 0.

covar
(time_interval, **kwargs)¶ Model covariance

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

matrix
(time_interval, **kwargs)¶ Model matrix

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
ConstantVelocity
(noise_diff_coeff)[source]¶ Bases:
stonesoup.models.transition.linear.ConstantNthDerivative
This is a class implementation of a discrete, timevariant 1D LinearGaussian Constant Velocity Transition Model.
The target is assumed to move with (nearly) constant velocity, where target acceleration is modelled as white noise.
The model is described by the following SDEs:
\begin{eqnarray} dx_{pos} & = & x_{vel} d &  {Position \ on \ Xaxis (m)} \\ dx_{vel} & = & q\cdot dW_t,\ W_t \sim \mathcal{N}(0,q^2) &  \ Speed on\ Xaxis (m/s) \end{eqnarray}Or equivalently:
\[x_t = F_t x_{t1} + w_t,\ w_t \sim \mathcal{N}(0,Q_t)\]where:
\[\begin{split}x & = & \begin{bmatrix} x_{pos} \\ x_{vel} \end{bmatrix}\end{split}\]\[\begin{split}F_t & = & \begin{bmatrix} 1 & dt\\ 0 & 1 \end{bmatrix}\end{split}\]\[\begin{split}Q_t & = & \begin{bmatrix} \frac{dt^3}{3} & \frac{dt^2}{2} \\ \frac{dt^2}{2} & dt \end{bmatrix} q\end{split}\] Parameters
noise_diff_coeff (
float
) – The velocity noise diffusion coefficient \(q\)

property
constant_derivative
¶ For constant velocity, this is 1.

covar
(time_interval, **kwargs)¶ Model covariance

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

matrix
(time_interval, **kwargs)¶ Model matrix

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
ConstantAcceleration
(noise_diff_coeff)[source]¶ Bases:
stonesoup.models.transition.linear.ConstantNthDerivative
This is a class implementation of a discrete, timevariant 1D Constant Acceleration Transition Model.
The target acceleration is modeled as a zeromean white noise random process.
The model is described by the following SDEs:
\begin{eqnarray} dx_{pos} & = & x_{vel} d &  {Position \ on \ Xaxis (m)} \\ dx_{vel} & = & x_{acc} d &  {Speed \ on\ Xaxis (m/s)} \\ dx_{acc} & = & q W_t,\ W_t \sim \mathcal{N}(0,q^2) &  {Acceleration \ on \ Xaxis (m^2/s)} \end{eqnarray}Or equivalently:
\[x_t = F_t x_{t1} + w_t,\ w_t \sim \mathcal{N}(0,Q_t)\]where:
\[\begin{split}x & = & \begin{bmatrix} x_{pos} \\ x_{vel} \\ x_{acc} \end{bmatrix}\end{split}\]\[\begin{split}F_t & = & \begin{bmatrix} 1 & dt & \frac{dt^2}{2} \\ 0 & 1 & dt \\ 0 & 0 & 1 \end{bmatrix}\end{split}\]\[\begin{split}Q_t & = & \begin{bmatrix} \frac{dt^5}{20} & \frac{dt^4}{8} & \frac{dt^3}{6} \\ \frac{dt^4}{8} & \frac{dt^3}{3} & \frac{dt^2}{2} \\ \frac{dt^3}{6} & \frac{dt^2}{2} & dt \end{bmatrix} q\end{split}\] Parameters
noise_diff_coeff (
float
) – The acceleration noise diffusion coefficient \(q\)

property
constant_derivative
¶ For constant acceleration, this is 2.

covar
(time_interval, **kwargs)¶ Model covariance

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

matrix
(time_interval, **kwargs)¶ Model matrix

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
NthDerivativeDecay
(decay_derivative, noise_diff_coeff, damping_coeff)[source]¶ Bases:
stonesoup.models.transition.linear.LinearGaussianTransitionModel
,stonesoup.models.base.TimeVariantModel
Discrete model based on the Nth derivative with respect to time decaying to 0 exponentially, to set derivative use keyword argument
decay_derivative
The model is described by the following SDEs:
\begin{eqnarray} dx^{(N1)} & = & x^{(N)} dt &  {(N1)th derivative \ on \ Xaxis (m)} \\ dx^{(N)} & = & K x^{N} dt + q\cdot dW_t,\ W_t \sim \mathcal{N}(0,q^2) &  \ Nth\ derivative\ on\ Xaxis (m/s^{N}) \end{eqnarray}The transition and covariance matrices are very difficult to express simply, but examples for N=1 and N=2 are given in
OrnsteinUhlenbeck
andSinger
respectively. Parameters
decay_derivative (
int
) – The derivative with respect to time to decay exponentially, eg if 2 identical to singernoise_diff_coeff (
float
) – The noise diffusion coefficient \(q\)damping_coeff (
float
) – The Nth derivative damping coefficient \(K\)

decay_derivative
: int¶ The derivative with respect to time to decay exponentially, eg if 2 identical to singer

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

property
ndim
¶ Number of dimensions of model

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
OrnsteinUhlenbeck
(noise_diff_coeff, damping_coeff)[source]¶ Bases:
stonesoup.models.transition.linear.NthDerivativeDecay
This is a class implementation of a discrete, timevariant 1D LinearGaussian Ornstein Uhlenbeck Transition Model.
The target is assumed to move with (nearly) constant velocity, which exponentially decays to zero over time, and target acceleration is modeled as white noise.
The model is described by the following SDEs:
\begin{eqnarray} dx_{pos} & = & x_{vel} dt &  {Position \ on \ Xaxis (m)} \\ dx_{vel} & = & K x_{vel} dt + q dW_t, W_t \sim \mathcal{N}(0,q) &  {Speed\ on \ Xaxis (m/s)} \end{eqnarray}Or equivalently:
\[x_t = F_t x_{t1} + w_t,\ w_t \sim \mathcal{N}(0,Q_t)\]where:
\[\begin{split}x & = & \begin{bmatrix} x_{pos} \\ x_{vel} \end{bmatrix}\end{split}\]\[\begin{split}F_t & = & \begin{bmatrix} 1 & \frac{1}{K}(1  e^{Kdt})\\ 0 & e^{Kdt} \end{bmatrix}\end{split}\]\[\begin{split}Q_t & = & \begin{bmatrix} \frac{dt  \frac{2}{K}(1  e^{Kdt}) + \frac{1}{2K}(1  e^{2Kdt})}{K^2} & \frac{\frac{1}{K}(1  e^{Kdt})  \frac{1}{2K}(1  e^{2Kdt})}{K} \\ \frac{\frac{1}{K}(1  e^{Kdt})  \frac{1}{2K}(1  e^{2Kdt})}{K} & \frac{1  e^{2Kdt}}{2K} \end{bmatrix} q\end{split}\] Parameters
noise_diff_coeff (
float
) – The velocity noise diffusion coefficient \(q\)damping_coeff (
float
) – The velocity damping coefficient \(K\)

property
decay_derivative
¶ The derivative with respect to time to decay exponentially, eg if 2 identical to singer

covar
(time_interval, **kwargs)¶ Model covariance

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

matrix
(time_interval, **kwargs)¶ Model matrix

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
Singer
(noise_diff_coeff, damping_coeff)[source]¶ Bases:
stonesoup.models.transition.linear.NthDerivativeDecay
This is a class implementation of a discrete, timevariant 1D Singer Transition Model.
The target acceleration is modeled as a zeromean GaussMarkov random process.
The model is described by the following SDEs:
\begin{eqnarray} dx_{pos} & = & x_{vel} dt &  {Position \ on \ Xaxis (m)} \\ dx_{vel} & = & x_{acc} dt &  {Speed \ on\ Xaxis (m/s)} \\ dx_{acc} & = & K x_{acc} dt + q W_t,\ W_t \sim \mathcal{N}(0,q^2) &  {Acceleration \ on \ Xaxis (m^2/s)} \end{eqnarray}Or equivalently:
\[x_t = F_t x_{t1} + w_t,\ w_t \sim \mathcal{N}(0,Q_t)\]where:
\[\begin{split}x & = & \begin{bmatrix} x_{pos} \\ x_{vel} \\ x_{acc} \end{bmatrix}\end{split}\]\[\begin{split}F_t & = & \begin{bmatrix} 1 & dt & (K dt1+e^{K dt})/K^2 \\ 0 & 1 & (1e^{K dt})/K \\ 0 & 0 & e^{K t} \end{bmatrix}\end{split}\]\[\begin{split}Q_t & = & q \begin{bmatrix} \frac{[1e^{2K dt}] + 2K dt + \frac{2K^3 dt^3}{3} 2K^2 dt^2  4K dt e^{K dt} }{2K^5} & \frac{(K dt  [1e^{K dt}])^2}{2K^4} & \frac{[1e^{2K dt}]2K dt e^{K dt}} {2K^3} \\ \frac{(K dt  [1  e^{K dt}])^2}{2K^4} & \frac{2K dt  4[1e^{K dt}] + [1e^{2K dt}]}{2K^3} & \frac{[1e^{K dt}]^2}{2K^2} \\ \frac{[1 e^{2K dt}]2K dt e^{K dt}} {2K^3} & \frac{[1e^{K dt}]^2}{2K^2} & \frac{1e^{2K dt}}{2K} \end{bmatrix}\end{split}\] Parameters
noise_diff_coeff (
float
) – The acceleration noise diffusion coefficient \(q\)damping_coeff (
float
) – The reciprocal of the decorrelation time \(\alpha\)

property
decay_derivative
¶ The derivative with respect to time to decay exponentially, eg if 2 identical to singer

covar
(time_interval, **kwargs)¶ Model covariance

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

matrix
(time_interval, **kwargs)¶ Model matrix

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
SingerApproximate
(noise_diff_coeff, damping_coeff)[source]¶ Bases:
stonesoup.models.transition.linear.Singer
 Parameters
noise_diff_coeff (
float
) – The acceleration noise diffusion coefficient \(q\)damping_coeff (
float
) – The reciprocal of the decorrelation time \(\alpha\)

property
decay_derivative
¶ The derivative with respect to time to decay exponentially, eg if 2 identical to singer

covar
(time_interval, **kwargs)[source]¶ Returns the transition model noise covariance matrix.
 Parameters
time_interval (
datetime.timedelta
) – A time interval \(dt\) Returns
The process noise covariance.
 Return type
stonesoup.types.state.CovarianceMatrix
of shape (ndim_state
,ndim_state
)

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

matrix
(time_interval, **kwargs)¶ Model matrix

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
ConstantTurnSandwich
(turn_noise_diff_coeffs, turn_rate, model_list)[source]¶ Bases:
stonesoup.models.transition.linear.LinearGaussianTransitionModel
,stonesoup.models.base.TimeVariantModel
This is a class implementation of a timevariant 2D Constant Turn Model. This model is used, as opposed to the normal
ConstantTurn
model, when the turn occurs in 2 dimensions that are not adjacent in the state vector, eg if the turn occurs in the xz plane but the state vector is of the form \((x,y,z)\). The list of transition models are to be applied to any state variables that lie in between, eg if for the above example you wanted the y component to move with constant velocity, you would put aConstantVelocity
model in the list.The target is assumed to move with (nearly) constant velocity and also known (nearly) constant turn rate.
 Parameters
turn_noise_diff_coeffs (
numpy.ndarray
) – The acceleration noise diffusion coefficients \(q\)turn_rate (
float
) – The turn rate \(\omega\)model_list (
Sequence[LinearGaussianTransitionModel]
) – List of Transition Models.

turn_noise_diff_coeffs
: numpy.ndarray¶ The acceleration noise diffusion coefficients \(q\)

model_list
: Sequence[stonesoup.models.transition.linear.LinearGaussianTransitionModel]¶ List of Transition Models.

property
ndim_state
¶ ndim_state getter method
 Returns
The number of combined model state dimensions.
 Return type

matrix
(time_interval, **kwargs)[source]¶ Model matrix \(F\)
 Returns
 Return type
numpy.ndarray
of shape (ndim_state
,ndim_state
)

covar
(time_interval, **kwargs)[source]¶ Returns the transition model noise covariance matrix.
 Returns
The process noise covariance.
 Return type
stonesoup.types.state.CovarianceMatrix
of shape (ndim_state
,ndim_state
)

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

property
ndim
¶ Number of dimensions of model

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

class
stonesoup.models.transition.linear.
ConstantTurn
(turn_noise_diff_coeffs, turn_rate)[source]¶ Bases:
stonesoup.models.transition.linear.ConstantTurnSandwich
This is a class implementation of a discrete, timevariant 2D Constant Turn Model.
The target is assumed to move with (nearly) constant velocity and also known (nearly) constant turn rate.
The model is described by the following SDEs:
\begin{eqnarray} dx_{pos} & = & x_{vel} d &  {Position \ on \ Xaxis (m)} \\ dx_{vel} & = &\omega y_{pos} d &  {Speed \ on\ Xaxis (m/s)} \\ dy_{pos} & = & y_{vel} d &  {Position \ on \ Yaxis (m)} \\ dy_{vel} & = & \omega x_{pos} d &  {Speed \ on\ Yaxis (m/s)} \end{eqnarray}Or equivalently:
\[x_t = F_t x_{t1} + w_t,\ w_t \sim \mathcal{N}(0,Q_t)\]where:
\[\begin{split}x & = & \begin{bmatrix} x_{pos} \\ x_{vel} \\ y_{pos} \\ y_{vel} \end{bmatrix}\end{split}\]\[\begin{split}F_t & = & \begin{bmatrix} 1 & \frac{\sin\omega dt}{\omega} & 0 &\frac{1\cos\omega dt}{\omega} \\ 0 & \cos\omega dt & 0 & \sin\omega dt \\ 0 & \frac{1\cos\omega dt}{\omega} & 1 & \frac{\sin\omega dt}{\omega}\\ 0 & \sin\omega dt & 0 & \cos\omega dt \end{bmatrix}\end{split}\]\[\begin{split}Q_t & = & \begin{bmatrix} q_x^2 \frac{dt^3}{3} & q_x^2 \frac{dt^2}{2} & 0 & 0 \\ q_x^2 \frac{dt^2}{2} & q_x^2 dt & 0 & 0 \\ 0 & 0 & q_y^2 \frac{dt^3}{3} & q_y^2 \frac{dt^2}{2}\\ 0 & 0 & q_y^2 \frac{dt^2}{2} & q_y^2 dt \end{bmatrix}\end{split}\] Parameters
turn_noise_diff_coeffs (
numpy.ndarray
) – The acceleration noise diffusion coefficients \(q\)turn_rate (
float
) – The turn rate \(\omega\)

property
model_list
¶ For a turn in adjacent state vectors, no transition models go in between

covar
(time_interval, **kwargs)¶ Returns the transition model noise covariance matrix.
 Returns
The process noise covariance.
 Return type
stonesoup.types.state.CovarianceMatrix
of shape (ndim_state
,ndim_state
)

function
(state, noise=False, **kwargs)¶ Model linear function \(f_k(x(k),w(k)) = F_k(x_k) + w_k\)
 Parameters
state (
State
) – An input statenoise (
numpy.ndarray
or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added if ‘True’, the output ofrvs()
is added)
 Returns
The updated State with the model function evaluated.
 Return type
State

matrix
(time_interval, **kwargs)¶ Model matrix \(F\)
 Returns
 Return type
numpy.ndarray
of shape (ndim_state
,ndim_state
)

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of combined model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)

turn_noise_diff_coeffs
: numpy.ndarray¶ The acceleration noise diffusion coefficients \(q\)
NonLinear¶

class
stonesoup.models.transition.nonlinear.
CombinedNonlinearGaussianTransitionModel
(model_list)[source]¶ Bases:
stonesoup.models.transition.base._CombinedGaussianTransitionModel
Combine multiple models into a single model by stacking them.
The assumption is that all models are Gaussian. Time Variant, and Time Invariant models can be combined together. If any of the models are time variant the keyword argument “time_interval” must be supplied to all methods
 Parameters
model_list (
Sequence[GaussianModel]
) – List of Transition Models.

function
(state, **kwargs) → stonesoup.types.array.StateVector[source]¶ Applies each transition model in
model_list
in turn to the state’s corresponding state vector components. For example, in a 3D state space, withmodel_list
= [modelA(ndim_state=2), modelB(ndim_state=1)], this would apply modelA to the state vector’s 1st and 2nd elements, then modelB to the remaining 3rd element. Parameters
state (
stonesoup.state.State
) – The state to be transitioned according to the models inmodel_list
. Returns
state_vector – of shape (
ndim_state, 1
). The resultant state vector of the transition. Return type

covar
(**kwargs)¶ Returns the transition model noise covariance matrix.
 Returns
The process noise covariance.
 Return type
stonesoup.types.state.CovarianceMatrix
of shape (ndim_state
,ndim_state
)

model_list
: Sequence[stonesoup.models.base.GaussianModel]¶ List of Transition Models.

property
ndim
¶ Number of dimensions of model

property
ndim_state
¶ ndim_state getter method
 Returns
The number of combined model state dimensions.
 Return type

pdf
(state1, state2, **kwargs)¶ Model pdf/likelihood evaluation function
Evaluates the pdf/likelihood of
state1
, given the statestate2
which is passed tofunction()
.In mathematical terms, this can be written as:
\[p = p(y_t  x_t) = \mathcal{N}(y_t; x_t, Q)\]where \(y_t\) =
state_vector1
, \(x_t\) =state_vector2
and \(Q\) =covar
. Parameters
 Returns
The likelihood of
state1
, givenstate2
 Return type

rvs
(num_samples=1, **kwargs)¶ Model noise/sample generation function
Generates noise samples from the model.
In mathematical terms, this can be written as:
\[v_t \sim \mathcal{N}(0,Q)\]where \(v_t =\)
noise
and \(Q\) =covar
. Parameters
num_samples (scalar, optional) – The number of samples to be generated (the default is 1)
 Returns
noise – A set of Np samples, generated from the model’s noise distribution.
 Return type
2D array of shape (
ndim
,num_samples
)