How to use the stonesoup.models.base.LinearModel function in stonesoup

To help you get started, we’ve selected a few stonesoup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dstl / Stone-Soup / stonesoup / models / transition / linear.py View on Github external
# -*- coding: utf-8 -*-

import scipy as sp
from scipy.stats import multivariate_normal
from scipy.linalg import block_diag

from ...base import Property
from ...types.array import CovarianceMatrix
from ..base import (LinearModel, GaussianModel, TimeVariantModel,
                    TimeInvariantModel)
from .base import TransitionModel


class LinearGaussianTransitionModel(
        TransitionModel, LinearModel, GaussianModel):

    @property
    def ndim_state(self):
        """ndim_state getter method

        Returns
        -------
        : :class:`int`
            The number of model state dimensions.
        """

        return self.matrix().shape[0]

    def rvs(self, num_samples=1, **kwargs):
        r""" Model noise/sample generation function
github dstl / Stone-Soup / stonesoup / predictor / kalman.py View on Github external
Parameters
        ----------
        prior : :class:`~.State`
            :math:`\mathbf{x}_{k-1}`
        **kwargs : various, optional
            These are passed to :meth:`~.TransitionModel.matrix` or
            :meth:`~.TransitionModel.jacobian`

        Returns
        -------
        : :class:`numpy.ndarray`
            The transition matrix, :math:`F_k`, if linear (i.e.
            :meth:`TransitionModel.matrix` exists, or
            :meth:`~.TransitionModel.jacobian` if not)
        """
        if isinstance(self.transition_model, LinearModel):
            return self.transition_model.matrix(**kwargs)
        else:
            return self.transition_model.jacobian(prior.state_vector, **kwargs)
github dstl / Stone-Soup / stonesoup / models / transition / orbital / orbit.py View on Github external
# -*- coding: utf-8 -*-

import numpy as np
from numpy import matlib
from scipy.stats import norm
from scipy.stats import multivariate_normal
from datetime import datetime, timedelta

from ....base import Property
from ....types.orbitalstate import OrbitalState, TLEOrbitalState
from ....types.array import CovarianceMatrix
from ...base import LinearModel, NonLinearModel
from .base import OrbitalTransitionModel


class SimpleMeanMotionTransitionModel(OrbitalTransitionModel, LinearModel):
    r"""This simple transition model uses the mean motion to update the
    mean anomaly and then use that to construct a new orbital state
    vector via the TLE parameterisation. Statistics assume a
    Gauss-distributed mean anomaly with all other quantities fixed.

    The transition proceeds as,

        .. math::

            M_{t_1} = M_{t_0} + n(t_1 - t_0), \; (\mathrm{modulo} \,
            2\pi)


    for the interval :math:`t_0 \rightarrow t_1`, where :math:`n` is
    the mean motion, computed as:
github dstl / Stone-Soup / stonesoup / models / transition / linear.py View on Github external
# -*- coding: utf-8 -*-
import math

import scipy as sp
from scipy.stats import multivariate_normal
from scipy.linalg import block_diag

from ...base import Property
from ...types.array import CovarianceMatrix
from ..base import (LinearModel, GaussianModel, TimeVariantModel,
                    TimeInvariantModel)
from .base import TransitionModel


class LinearGaussianTransitionModel(
        TransitionModel, LinearModel, GaussianModel):

    @property
    def ndim_state(self):
        """ndim_state getter method

        Returns
        -------
        : :class:`int`
            The number of model state dimensions.
        """

        return self.matrix().shape[0]

    def rvs(self, num_samples=1, **kwargs):
        r""" Model noise/sample generation function
github dstl / Stone-Soup / stonesoup / predictor / kalman.py View on Github external
def _control_matrix(self):
        r"""Returns the control input model matrix, :math:`B_k`, or its linear
        approximation via a Jacobian. The :class:`~.ControlModel`, if
        non-linear must therefore be capable of returning a
        :meth:`~.ControlModel.jacobian`,

        Returns
        -------
        : :class:`numpy.ndarray`
            The control model matrix, or its linear approximation
        """
        if isinstance(self.control_model, LinearModel):
            return self.control_model.matrix()
        else:
            return self.control_model.jacobian(
                self.control_model.control_vector)
github dstl / Stone-Soup / stonesoup / models / control / linear.py View on Github external
# -*- coding: utf-8 -*-

from scipy import ndarray
from scipy.stats import multivariate_normal

from .base import ControlModel
from ..base import LinearModel
from ...base import Property


class LinearControlModel(ControlModel, LinearModel):
    r"""Implements a linear effect to the state vector via,

    .. math::

        \hat{x}_k = B_k \mathbf{u}_k + \gamma_k

    where :math:`B_k` is the control-input model matrix (i.e. control matrix),
    :math:`\mathbf{u}_k` is the control vector and :math:`\gamma_k` is
    sampled from zero-mean white noise distribution
    :math:`\mathcal{N}(0,\Gamma_k)`

    """

    control_vector = Property(
        ndarray, doc="Control vector at time :math:`k`")
    control_matrix = Property(
github dstl / Stone-Soup / stonesoup / models / measurement / linear.py View on Github external
# -*- coding: utf-8 -*-

import scipy as sp
from scipy.stats import multivariate_normal

from ...base import Property
from ...types.array import CovarianceMatrix
from ..base import LinearModel, GaussianModel
from .base import MeasurementModel


# TODO Probably should call this LinearGaussianMeasurementModel
class LinearGaussian(MeasurementModel, LinearModel, GaussianModel):
    r"""This is a class implementation of a time-invariant 1D
    Linear-Gaussian Measurement Model.

    The model is described by the following equations:

    .. math::

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

    where ``H_k`` is a (:py:attr:`~ndim_meas`, :py:attr:`~ndim_state`) \
    matrix and ``v_k`` is Gaussian distributed.

    """

    noise_covar = Property(CovarianceMatrix, doc="Noise covariance")