# Measurement Models¶

class stonesoup.models.measurement.base.MeasurementModel(ndim_state: int, mapping: Sequence[int])[source]

Measurement Model base class

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

ndim_state: int

Number of state dimensions

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

abstract property ndim_meas: int

Number of measurement dimensions

## Linear¶

class stonesoup.models.measurement.linear.LinearGaussian(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, seed: Optional[int] = None)[source]

This is a class implementation of a time-invariant 1D Linear-Gaussian Measurement Model.

The model is described by the following equations:

$y_t = H_k*x_t + v_k,\ \ \ \ v(k)\sim \mathcal{N}(0,R)$

where H_k is a (ndim_meas, ndim_state) matrix and v_k is Gaussian distributed.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• seed (Union[int, NoneType], optional) – Seed for random number generation

noise_covar: stonesoup.types.array.CovarianceMatrix

Noise covariance

property ndim_meas

ndim_meas getter method

Returns

The number of measurement dimensions

Return type

int

matrix(**kwargs)[source]

Model matrix $$H(t)$$

Returns

The model matrix evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_meas, ndim_state)

function(state, noise=False, **kwargs)[source]

Model function $$h(t,x(t),w(t))$$

Parameters
Returns

The model function evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_meas, 1)

covar(**kwargs)[source]

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

ndim_state: int

Number of state dimensions

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
rvs(num_samples: int = 1, random_state=None, **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

2-D array of shape (ndim, num_samples)

seed: Optional[int]

Seed for random number generation

## NonLinear¶

class stonesoup.models.measurement.nonlinear.CombinedReversibleGaussianMeasurementModel(model_list: Sequence[GaussianModel], seed: Optional[int] = None)[source]

Combine multiple models into a single model by stacking them.

The assumption is that all models are Gaussian, and must be combination of LinearModel and NonLinearModel models. They must all expect the same dimension state vector (i.e. have the same ndim_state), using model mapping as appropriate.

This also implements the inverse_function(), but will raise a NotImplementedError if any model isn’t either a LinearModel or ReversibleModel.

Parameters
• model_list (Sequence[GaussianModel]) – List of Measurement Models.

• seed (Union[int, NoneType], optional) – Seed for random number generation

model_list: Sequence[stonesoup.models.base.GaussianModel]

List of Measurement Models.

property ndim_state: int

Number of state dimensions

property ndim_meas: int

Number of measurement dimensions

property mapping

Mapping between measurement and state dims

function(state, **kwargs) [source]

Model function $$f_k(x(k),w(k))$$

Parameters
Returns

The StateVector(s) with the model function evaluated.

Return type

StateVector or StateVectors

inverse_function(detection, **kwargs) [source]

Takes in the result of the function and computes the inverse function, returning the initial input of the function.

Parameters

detection (Detection) – Input state (non-linear format)

Returns

The linear co-ordinates

Return type

StateVector

covar(**kwargs) [source]

Model covariance

rvs(num_samples=1, **kwargs) [source]

Model noise/sample generation function

Generates noise samples from the model.

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

2-D array of shape (ndim, num_samples)

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

property ndim: int

Number of dimensions of model

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
seed: Optional[int]

Seed for random number generation

class stonesoup.models.measurement.nonlinear.NonLinearGaussianMeasurement(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, seed: Optional[int] = None, rotation_offset: StateVector = None)[source]

This class combines the MeasurementModel, NonLinearModel and GaussianModel classes. It is not meant to be instantiated directly but subclasses should be derived from this class.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• seed (Union[int, NoneType], optional) – Seed for random number generation

• rotation_offset (StateVector, optional) – A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

noise_covar: stonesoup.types.array.CovarianceMatrix

Noise covariance

rotation_offset: stonesoup.types.array.StateVector

A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

covar(**kwargs) [source]

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

abstract function(state: State, noise: Union[bool, numpy.ndarray] = False, **kwargs)

Model function $$f_k(x(k),w(k))$$

Parameters
Returns

The StateVector(s) with the model function evaluated.

Return type

StateVector or StateVectors

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

abstract property ndim_meas: int

Number of measurement dimensions

ndim_state: int

Number of state dimensions

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
rvs(num_samples: int = 1, random_state=None, **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

2-D array of shape (ndim, num_samples)

seed: Optional[int]

Seed for random number generation

class stonesoup.models.measurement.nonlinear.CartesianToElevationBearingRange(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, seed: Optional[int] = None, rotation_offset: StateVector = None, translation_offset: StateVector = None)[source]

This is a class implementation of a time-invariant measurement model, where measurements are assumed to be received in the form of bearing ($$\phi$$), elevation ($$\theta$$) and range ($$r$$), with Gaussian noise in each dimension.

The model is described by the following equations:

$\vec{y}_t = h(\vec{x}_t, \vec{v}_t)$

where:

• $$\vec{y}_t$$ is a measurement vector of the form:

$\begin{split}\vec{y}_t = \begin{bmatrix} \theta \\ \phi \\ r \end{bmatrix}\end{split}$
• $$h$$ is a non-linear model function of the form:

$\begin{split}h(\vec{x}_t,\vec{v}_t) = \begin{bmatrix} asin(\mathcal{z}/\sqrt{\mathcal{x}^2 + \mathcal{y}^2 +\mathcal{z}^2}) \\ atan2(\mathcal{y},\mathcal{x}) \\ \sqrt{\mathcal{x}^2 + \mathcal{y}^2 + \mathcal{z}^2} \end{bmatrix} + \vec{v}_t\end{split}$
• $$\vec{v}_t$$ is Gaussian distributed with covariance $$R$$, i.e.:

$\vec{v}_t \sim \mathcal{N}(0,R)$
$\begin{split}R = \begin{bmatrix} \sigma_{\theta}^2 & 0 & 0 \\ 0 & \sigma_{\phi}^2 & 0 \\ 0 & 0 & \sigma_{r}^2 \end{bmatrix}\end{split}$

The mapping property of the model is a 3 element vector, whose first (i.e. mapping[0]), second (i.e. mapping[1]) and third (i.e. mapping[2) elements contain the state index of the $$x$$, $$y$$ and $$z$$ coordinates, respectively.

Note

The current implementation of this class assumes a 3D Cartesian plane.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• seed (Union[int, NoneType], optional) – Seed for random number generation

• rotation_offset (StateVector, optional) – A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

• translation_offset (StateVector, optional) – A 3x1 array specifying the Cartesian origin offset in terms of $$x,y,z$$ coordinates.

translation_offset: stonesoup.types.array.StateVector

A 3x1 array specifying the Cartesian origin offset in terms of $$x,y,z$$ coordinates.

property ndim_meas: int

ndim_meas getter method

Returns

The number of measurement dimensions

Return type

int

function(state, noise=False, **kwargs) [source]

Model function $$h(\vec{x}_t,\vec{v}_t)$$

Parameters
Returns

The model function evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_state, 1)

inverse_function(detection, **kwargs) [source]

Takes in the result of the function and computes the inverse function, returning the initial input of the function.

Parameters

detection (Detection) – Input state (non-linear format)

Returns

The linear co-ordinates

Return type

StateVector

rvs(num_samples=1, **kwargs) [source]

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

2-D array of shape (ndim, num_samples)

covar(**kwargs)

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

ndim_state: int

Number of state dimensions

noise_covar: CovarianceMatrix

Noise covariance

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
rotation_offset: StateVector

A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

seed: Optional[int]

Seed for random number generation

class stonesoup.models.measurement.nonlinear.CartesianToBearingRange(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, seed: Optional[int] = None, rotation_offset: StateVector = None, translation_offset: StateVector = None)[source]

This is a class implementation of a time-invariant measurement model, where measurements are assumed to be received in the form of bearing ($$\phi$$) and range ($$r$$), with Gaussian noise in each dimension.

The model is described by the following equations:

$\vec{y}_t = h(\vec{x}_t, \vec{v}_t)$

where:

• $$\vec{y}_t$$ is a measurement vector of the form:

$\begin{split}\vec{y}_t = \begin{bmatrix} \phi \\ r \end{bmatrix}\end{split}$
• $$h$$ is a non-linear model function of the form:

$\begin{split}h(\vec{x}_t,\vec{v}_t) = \begin{bmatrix} atan2(\mathcal{y},\mathcal{x}) \\ \sqrt{\mathcal{x}^2 + \mathcal{y}^2} \end{bmatrix} + \vec{v}_t\end{split}$
• $$\vec{v}_t$$ is Gaussian distributed with covariance $$R$$, i.e.:

$\vec{v}_t \sim \mathcal{N}(0,R)$
$\begin{split}R = \begin{bmatrix} \sigma_{\phi}^2 & 0 \\ 0 & \sigma_{r}^2 \end{bmatrix}\end{split}$

The mapping property of the model is a 2 element vector, whose first (i.e. mapping[0]) and second (i.e. mapping[0]) elements contain the state index of the $$x$$ and $$y$$ coordinates, respectively.

Note

The current implementation of this class assumes a 2D Cartesian plane.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• seed (Union[int, NoneType], optional) – Seed for random number generation

• rotation_offset (StateVector, optional) – A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

• translation_offset (StateVector, optional) – A 2x1 array specifying the origin offset in terms of $$x,y$$ coordinates.

translation_offset: stonesoup.types.array.StateVector

A 2x1 array specifying the origin offset in terms of $$x,y$$ coordinates.

property ndim_meas: int

ndim_meas getter method

Returns

The number of measurement dimensions

Return type

int

inverse_function(detection, **kwargs) [source]

Takes in the result of the function and computes the inverse function, returning the initial input of the function.

Parameters

detection (Detection) – Input state (non-linear format)

Returns

The linear co-ordinates

Return type

StateVector

function(state, noise=False, **kwargs) [source]

Model function $$h(\vec{x}_t,\vec{v}_t)$$

Parameters
Returns

The model function evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_meas, 1)

rvs(num_samples=1, **kwargs) [source]

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

2-D array of shape (ndim, num_samples)

covar(**kwargs)

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

ndim_state: int

Number of state dimensions

noise_covar: CovarianceMatrix

Noise covariance

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
rotation_offset: StateVector

A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

seed: Optional[int]

Seed for random number generation

class stonesoup.models.measurement.nonlinear.CartesianToElevationBearing(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, seed: Optional[int] = None, rotation_offset: StateVector = None, translation_offset: StateVector = None)[source]

This is a class implementation of a time-invariant measurement model, where measurements are assumed to be received in the form of bearing ($$\phi$$) and elevation ($$\theta$$) and with Gaussian noise in each dimension.

The model is described by the following equations:

$\vec{y}_t = h(\vec{x}_t, \vec{v}_t)$

where:

• $$\vec{y}_t$$ is a measurement vector of the form:

$\begin{split}\vec{y}_t = \begin{bmatrix} \theta \\ \phi \end{bmatrix}\end{split}$
• $$h$$ is a non-linear model function of the form:

$\begin{split}h(\vec{x}_t,\vec{v}_t) = \begin{bmatrix} asin(\mathcal{z}/\sqrt{\mathcal{x}^2 + \mathcal{y}^2 +\mathcal{z}^2}) \\ atan2(\mathcal{y},\mathcal{x}) \\ \end{bmatrix} + \vec{v}_t\end{split}$
• $$\vec{v}_t$$ is Gaussian distributed with covariance $$R$$, i.e.:

$\vec{v}_t \sim \mathcal{N}(0,R)$
$\begin{split}R = \begin{bmatrix} \sigma_{\theta}^2 & 0 \\ 0 & \sigma_{\phi}^2\\ \end{bmatrix}\end{split}$

The mapping property of the model is a 3 element vector, whose first (i.e. mapping[0]), second (i.e. mapping[1]) and third (i.e. mapping[2]) elements contain the state index of the $$x$$, $$y$$ and $$z$$ coordinates, respectively.

Note

The current implementation of this class assumes a 3D Cartesian plane.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• seed (Union[int, NoneType], optional) – Seed for random number generation

• rotation_offset (StateVector, optional) – A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

• translation_offset (StateVector, optional) – A 3x1 array specifying the origin offset in terms of $$x,y,z$$ coordinates.

translation_offset: stonesoup.types.array.StateVector

A 3x1 array specifying the origin offset in terms of $$x,y,z$$ coordinates.

property ndim_meas: int

ndim_meas getter method

Returns

The number of measurement dimensions

Return type

int

function(state, noise=False, **kwargs) [source]

Model function $$h(\vec{x}_t,\vec{v}_t)$$

Parameters
Returns

The model function evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_state, 1)

rvs(num_samples=1, **kwargs) [source]

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

2-D array of shape (ndim, num_samples)

covar(**kwargs)

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

ndim_state: int

Number of state dimensions

noise_covar: CovarianceMatrix

Noise covariance

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
rotation_offset: StateVector

A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

seed: Optional[int]

Seed for random number generation

class stonesoup.models.measurement.nonlinear.Cartesian2DToBearing(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, seed: Optional[int] = None, rotation_offset: StateVector = None, translation_offset: StateVector = None)[source]

This is a class implementation of a time-invariant measurement model, where measurements are assumed to be received in the form of bearing ($$\phi$$) with Gaussian noise.

The model is described by the following equations:

$\phi_t = h(\vec{x}_t, v_t)$
• $$h$$ is a non-linear model function of the form:

$h(\vec{x}_t,v_t) = atan2(\mathcal{y},\mathcal{x}) + v_t$
• $$v_t$$ is Gaussian distributed with covariance $$R$$, i.e.:

$v_t \sim \mathcal{N}(0,\sigma_{\phi}^2)$

The mapping property of the model is a 2 element vector, whose first (i.e. mapping[0]) and second (i.e. mapping[1]) elements contain the state index of the $$x$$ and $$y$$ coordinates, respectively.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• seed (Union[int, NoneType], optional) – Seed for random number generation

• rotation_offset (StateVector, optional) – A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

• translation_offset (StateVector, optional) – A 2x1 array specifying the origin offset in terms of $$x,y$$ coordinates.

translation_offset: stonesoup.types.array.StateVector

A 2x1 array specifying the origin offset in terms of $$x,y$$ coordinates.

property ndim_meas

ndim_meas getter method

Returns

The number of measurement dimensions

Return type

int

function(state, noise=False, **kwargs)[source]

Model function $$h(\vec{x}_t,v_t)$$

Parameters
Returns

The model function evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_state, 1)

rvs(num_samples=1, **kwargs) [source]

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

2-D array of shape (ndim, num_samples)

covar(**kwargs)

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

ndim_state: int

Number of state dimensions

noise_covar: CovarianceMatrix

Noise covariance

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
rotation_offset: StateVector

A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

seed: Optional[int]

Seed for random number generation

class stonesoup.models.measurement.nonlinear.CartesianToBearingRangeRate(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, seed: Optional[int] = None, rotation_offset: StateVector = None, translation_offset: StateVector = None, velocity_mapping: Tuple[int, int, int] = (1, 3, 5), velocity: StateVector = None)[source]

This is a class implementation of a time-invariant measurement model, where measurements are assumed to be received in the form of bearing ($$\phi$$), range ($$r$$) and range-rate ($$\dot{r}$$), with Gaussian noise in each dimension.

The model is described by the following equations:

$\vec{y}_t = h(\vec{x}_t, \vec{v}_t)$

where:

• $$\vec{y}_t$$ is a measurement vector of the form:

$\begin{split}\vec{y}_t = \begin{bmatrix} \phi \\ r \\ \dot{r} \end{bmatrix}\end{split}$
• $$h$$ is a non-linear model function of the form:

$\begin{split}h(\vec{x}_t,\vec{v}_t) = \begin{bmatrix} atan2(\mathcal{y},\mathcal{x}) \\ \sqrt{\mathcal{x}^2 + \mathcal{y}^2} \\ (x\dot{x} + y\dot{y})/\sqrt{x^2 + y^2} \end{bmatrix} + \vec{v}_t\end{split}$
• $$\vec{v}_t$$ is Gaussian distributed with covariance $$R$$, i.e.:

$\vec{v}_t \sim \mathcal{N}(0,R)$
$\begin{split}R = \begin{bmatrix} \sigma_{\phi}^2 & 0 & 0\\ 0 & \sigma_{r}^2 & 0 \\ 0 & 0 & \sigma_{\dot{r}}^2 \end{bmatrix}\end{split}$

The mapping property of the model is a 3 element vector, whose first (i.e. mapping[0]), second (i.e. mapping[1]) and third (i.e. mapping[2]) elements contain the state index of the $$x$$, $$y$$ and $$z$$ coordinates, respectively.

Note

This class implementation assuming at 3D cartesian space, it therefore expects a 6D state space.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• seed (Union[int, NoneType], optional) – Seed for random number generation

• rotation_offset (StateVector, optional) – A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

• translation_offset (StateVector, optional) – A 3x1 array specifying the origin offset in terms of $$x,y$$ coordinates.

• velocity_mapping (Tuple[int, int, int], optional) – Mapping to the targets velocity within its state space

• velocity (StateVector, optional) – A 3x1 array specifying the sensor velocity in terms of $$x,y,z$$ coordinates.

velocity_mapping: Tuple[int, int, int]

Mapping to the targets velocity within its state space

translation_offset: stonesoup.types.array.StateVector

A 3x1 array specifying the origin offset in terms of $$x,y$$ coordinates.

velocity: stonesoup.types.array.StateVector

A 3x1 array specifying the sensor velocity in terms of $$x,y,z$$ coordinates.

property ndim_meas: int

ndim_meas getter method

Returns

The number of measurement dimensions

Return type

int

function(state, noise=False, **kwargs) [source]

Model function $$h(\vec{x}_t,\vec{v}_t)$$

Parameters
Returns

The model function evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_state, 1)

rvs(num_samples=1, **kwargs) [source]

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

2-D array of shape (ndim, num_samples)

covar(**kwargs)

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

ndim_state: int

Number of state dimensions

noise_covar: CovarianceMatrix

Noise covariance

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
rotation_offset: StateVector

A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

seed: Optional[int]

Seed for random number generation

class stonesoup.models.measurement.nonlinear.CartesianToElevationBearingRangeRate(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, seed: Optional[int] = None, rotation_offset: StateVector = None, translation_offset: StateVector = None, velocity_mapping: Tuple[int, int, int] = (1, 3, 5), velocity: StateVector = None)[source]

This is a class implementation of a time-invariant measurement model, where measurements are assumed to be received in the form of elevation ($$\theta$$), bearing ($$\phi$$), range ($$r$$) and range-rate ($$\dot{r}$$), with Gaussian noise in each dimension.

The model is described by the following equations:

$\vec{y}_t = h(\vec{x}_t, \vec{v}_t)$

where:

• $$\vec{y}_t$$ is a measurement vector of the form:

$\begin{split}\vec{y}_t = \begin{bmatrix} \theta \\ \phi \\ r \\ \dot{r} \end{bmatrix}\end{split}$
• $$h$$ is a non-linear model function of the form:

$\begin{split}h(\vec{x}_t,\vec{v}_t) = \begin{bmatrix} asin(\mathcal{z}/\sqrt{\mathcal{x}^2 + \mathcal{y}^2 +\mathcal{z}^2}) \\ atan2(\mathcal{y},\mathcal{x}) \\ \sqrt{\mathcal{x}^2 + \mathcal{y}^2 + \mathcal{z}^2} \\ (x\dot{x} + y\dot{y} + z\dot{z})/\sqrt{x^2 + y^2 + z^2} \end{bmatrix} + \vec{v}_t\end{split}$
• $$\vec{v}_t$$ is Gaussian distributed with covariance $$R$$, i.e.:

$\vec{v}_t \sim \mathcal{N}(0,R)$
$\begin{split}R = \begin{bmatrix} \sigma_{\theta}^2 & 0 & 0 & 0\\ 0 & \sigma_{\phi}^2 & 0 & 0\\ 0 & 0 & \sigma_{r}^2 & 0\\ 0 & 0 & 0 & \sigma_{\dot{r}}^2 \end{bmatrix}\end{split}$

The mapping property of the model is a 3 element vector, whose first (i.e. mapping[0]), second (i.e. mapping[1]) and third (i.e. mapping[2]) elements contain the state index of the $$x$$, $$y$$ and $$z$$ coordinates, respectively.

Note

This class implementation assuming at 3D cartesian space, it therefore expects a 6D state space.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• seed (Union[int, NoneType], optional) – Seed for random number generation

• rotation_offset (StateVector, optional) – A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

• translation_offset (StateVector, optional) – A 3x1 array specifying the origin offset in terms of $$x,y,z$$ coordinates.

• velocity_mapping (Tuple[int, int, int], optional) – Mapping to the targets velocity within its state space

• velocity (StateVector, optional) – A 3x1 array specifying the sensor velocity in terms of $$x,y,z$$ coordinates.

velocity_mapping: Tuple[int, int, int]

Mapping to the targets velocity within its state space

translation_offset: stonesoup.types.array.StateVector

A 3x1 array specifying the origin offset in terms of $$x,y,z$$ coordinates.

velocity: stonesoup.types.array.StateVector

A 3x1 array specifying the sensor velocity in terms of $$x,y,z$$ coordinates.

property ndim_meas: int

ndim_meas getter method

Returns

The number of measurement dimensions

Return type

int

function(state, noise=False, **kwargs) [source]

Model function $$h(\vec{x}_t,\vec{v}_t)$$

Parameters
Returns

The model function evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_state, 1)

inverse_function(detection, **kwargs) [source]

Takes in the result of the function and computes the inverse function, returning the initial input of the function.

Parameters

detection (Detection) – Input state (non-linear format)

Returns

The linear co-ordinates

Return type

StateVector

covar(**kwargs)

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

ndim_state: int

Number of state dimensions

noise_covar: CovarianceMatrix

Noise covariance

pdf(state1: State, state2: State, **kwargs)

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

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, given state2

Return type
rotation_offset: StateVector

A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

rvs(num_samples=1, **kwargs) [source]

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

2-D array of shape (ndim, num_samples)

seed: Optional[int]

Seed for random number generation

class stonesoup.models.measurement.nonlinear.RangeRangeRateBinning(ndim_state: int, mapping: Sequence[int], noise_covar: CovarianceMatrix, range_res: float, range_rate_res: float, seed: Optional[int] = None, rotation_offset: StateVector = None, translation_offset: StateVector = None, velocity_mapping: Tuple[int, int, int] = (1, 3, 5), velocity: StateVector = None)[source]

This is a class implementation of a time-invariant measurement model, where measurements are assumed to be in the form of elevation ($$\theta$$), bearing ($$\phi$$), range ($$r$$) and range-rate ($$\dot{r}$$), with Gaussian noise in each dimension and the range and range-rate are binned based on the range resolution and range-rate resolution respectively.

The model is described by the following equations:

$\vec{y}_t = h(\vec{x}_t, \vec{v}_t)$

where:

• $$\vec{y}_t$$ is a measurement vector of the form:

$\begin{split}\vec{y}_t = \begin{bmatrix} \theta \\ \phi \\ r \\ \dot{r} \end{bmatrix}\end{split}$
• $$h$$ is a non-linear model function of the form:

$\begin{split}h(\vec{x}_t,\vec{v}_t) = \begin{bmatrix} \textrm{asin}(\mathcal{z}/\sqrt{\mathcal{x}^2 + \mathcal{y}^2 +\mathcal{z}^2}) \\ \textrm{atan2}(\mathcal{y},\mathcal{x}) \\ \sqrt{\mathcal{x}^2 + \mathcal{y}^2 + \mathcal{z}^2} \\ (x\dot{x} + y\dot{y} + z\dot{z})/\sqrt{x^2 + y^2 + z^2} \end{bmatrix} + \vec{v}_t\end{split}$
• $$\vec{v}_t$$ is Gaussian distributed with covariance $$R$$, i.e.:

$\vec{v}_t \sim \mathcal{N}(0,R)$
$\begin{split}R = \begin{bmatrix} \sigma_{\theta}^2 & 0 & 0 & 0\\ 0 & \sigma_{\phi}^2 & 0 & 0\\ 0 & 0 & \sigma_{r}^2 & 0\\ 0 & 0 & 0 & \sigma_{\dot{r}}^2 \end{bmatrix}\end{split}$

The covariances for radar are determined by different factors. The angle error is affected by the radar beam width. Range error is affected by the SNR and pulse bandwidth. The error for the range rate is dependent on the dwell time. The range and range rate are binned to the centre of the cell using

$x = \textrm{floor}(x/\Delta x)*\Delta x + \frac{\Delta x}{2}$

The mapping property of the model is a 3 element vector, whose first (i.e. mapping[0]), second (i.e. mapping[1]) and third (i.e. mapping[2]) elements contain the state index of the $$x$$, $$y$$ and $$z$$ coordinates, respectively.

The velocity_mapping property of the model is a 3 element vector, whose first (i.e. velocity_mapping[0]), second (i.e. velocity_mapping[1]) and third (i.e. velocity_mapping[2]) elements contain the state index of the $$\dot{x}$$, $$\dot{y}$$ and $$\dot{z}$$ coordinates, respectively.

Note

This class implementation assumes a 3D cartesian space, it therefore expects a 6D state space.

Parameters
• ndim_state (int) – Number of state dimensions

• mapping (Sequence[int]) – Mapping between measurement and state dims

• noise_covar (CovarianceMatrix) – Noise covariance

• range_res (float) – Size of the range bins in m

• range_rate_res (float) – Size of the velocity bins in m/s

• seed (Union[int, NoneType], optional) – Seed for random number generation

• rotation_offset (StateVector, optional) – A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

• translation_offset (StateVector, optional) – A 3x1 array specifying the origin offset in terms of $$x,y,z$$ coordinates.

• velocity_mapping (Tuple[int, int, int], optional) – Mapping to the targets velocity within its state space

• velocity (StateVector, optional) – A 3x1 array specifying the sensor velocity in terms of $$x,y,z$$ coordinates.

covar(**kwargs)

Returns the measurement model noise covariance matrix.

Returns

The measurement noise covariance.

Return type

CovarianceMatrix of shape (ndim_meas, ndim_meas)

inverse_function(detection, **kwargs)

Takes in the result of the function and computes the inverse function, returning the initial input of the function.

Parameters

detection (Detection) – Input state (non-linear format)

Returns

The linear co-ordinates

Return type

StateVector

jacobian(state: State, **kwargs)

Model Jacobian matrix $$H_{jac}$$

Parameters

state (State) – An input state

Returns

:class:numpy.ndarray of shape (attr – The model Jacobian matrix evaluated around the given state vector.

Return type

~ndim_meas, ndim_state)

mapping: Sequence[int]

Mapping between measurement and state dims

property ndim: int

Number of dimensions of model

ndim_state: int

Number of state dimensions

noise_covar: CovarianceMatrix

Noise covariance

rotation_offset: StateVector

A 3x1 array of angles (rad), specifying the clockwise rotation around each Cartesian axis in the order $$x,y,z$$. The rotation angles are positive if the rotation is in the counter-clockwise direction when viewed by an observer looking along the respective rotation axis, towards the origin.

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

2-D array of shape (ndim, num_samples)

seed: Optional[int]

Seed for random number generation

translation_offset: StateVector

A 3x1 array specifying the origin offset in terms of $$x,y,z$$ coordinates.

velocity: StateVector

A 3x1 array specifying the sensor velocity in terms of $$x,y,z$$ coordinates.

velocity_mapping: Tuple[int, int, int]

Mapping to the targets velocity within its state space

range_res: float

Size of the range bins in m

range_rate_res: float

Size of the velocity bins in m/s

property ndim_meas

ndim_meas getter method

Returns

The number of measurement dimensions

Return type

int

function(state, noise=False, **kwargs)[source]

Model function $$h(\vec{x}_t,\vec{v}_t)$$

Parameters
• state (StateVector) – An input state vector for the target

• noise (numpy.ndarray or bool) – An externally generated random process noise sample (the default is False, in which case no noise will be added and no binning takes place if True, the output of rvs is added and the range and range rate are binned)

Returns

The model function evaluated given the provided time interval.

Return type

numpy.ndarray of shape (ndim_state, 1)

pdf(state1, state2, **kwargs)[source]

Model pdf/likelihood evaluation function

Evaluates the pdf/likelihood of state1, given the state state2 which is passed to function().

For the first 2 dimensions, 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,

$$Q$$ = covar and $$\mathcal{N}$$ is a normal distribution

The probability for the binned dimensions, the last 2, can be written as:

$p = P(a \leq \mathcal{N} \leq b)$

In this equation a and b are the edges of the bin.

Parameters
Returns

The likelihood of state1, given state2

Return type

Probability