How to use the stonesoup.types.state.GaussianState 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 / types / detection.py View on Github external
class Detection(State):
    """Detection type"""
    measurement_model = Property(MeasurementModel, default=None,
                                 doc="The measurement model used to generate the detection\
                         (the default is ``None``)")

    metadata = Property(dict, default=None,
                        doc='Dictionary of metadata items for Detections.')

    def __init__(self, state_vector, *args, **kwargs):
        super().__init__(state_vector, *args, **kwargs)
        if self.metadata is None:
            self.metadata = {}


class GaussianDetection(Detection, GaussianState):
    """GaussianDetection type"""


class Clutter(Detection):
    """Clutter type for detections classed as clutter

    This is same as :class:`~.Detection`, but can be used to identify clutter
    for metrics and analysis purposes.
    """


class TrueDetection(Detection):
    """TrueDetection type for detections that come from ground truth

    This is same as :class:`~.Detection`, but can be used to identify true
    detections for metrics and analysis purposes.
github dstl / Stone-Soup / stonesoup / types / update.py View on Github external
and contain the information that was used to perform the updating"""

    hypothesis = Property(Hypothesis,
                          doc="Hypothesis used for updating")


class StateUpdate(Update, State):
    """ StateUpdate type

    Most simple state update type, where everything only has time
    and a state vector. Requires a prior state that was updated,
    and the hypothesis used to update the prior.
    """


class GaussianStateUpdate(Update, GaussianState):
    """ GaussianStateUpdate type

    This is a simple Gaussian state update object, which, as the name
    suggests, is described by a Gaussian distribution.
    """


class ParticleStateUpdate(Update, ParticleState):
    """ParticleStateUpdate type
github dstl / Stone-Soup / stonesoup / types / prediction.py View on Github external
class StatePrediction(State, Prediction):
    """ StatePrediction type

    Most simple state prediction type, which only has time and a state vector.
    """


class StateMeasurementPrediction(State, MeasurementPrediction):
    """ MeasurementPrediction type

    Most simple measurement prediction type, which only has time and a state
    vector.
    """


class GaussianStatePrediction(Prediction, GaussianState):
    """ GaussianStatePrediction type

    This is a simple Gaussian state prediction object, which, as the name
    suggests, is described by a Gaussian distribution.
    """


class GaussianMeasurementPrediction(MeasurementPrediction, GaussianState):
    """ GaussianMeasurementPrediction type

    This is a simple Gaussian measurement prediction object, which, as the name
    suggests, is described by a Gaussian distribution.
    """

    cross_covar = Property(CovarianceMatrix,
                           doc="The state-measurement cross covariance matrix",
github dstl / Stone-Soup / stonesoup / simulator / simple.py View on Github external
def transition_model(self):
        self.index = np.random.choice(range(0, len(self.transition_models)),
                                      p=self.model_probs[self.index])
        return self.transition_models[self.index]


class MultiTargetGroundTruthSimulator(SingleTargetGroundTruthSimulator):
    """Target simulator that produces multiple targets.

    Targets are created and destroyed randomly, as defined by the birth rate
    and death probability."""
    transition_model = Property(
        TransitionModel, doc="Transition Model used as propagator for track.")

    initial_state = Property(
        GaussianState,
        doc="Initial state to use to generate states")
    birth_rate = Property(
        float, default=1.0, doc="Rate at which tracks are born. Expected "
        "number of occurrences (λ) in Poisson distribution. Default 1.0.")
    death_probability = Property(
        Probability, default=0.1,
        doc="Probability of track dying in each time step. Default 0.1.")

    @BufferedGenerator.generator_method
    def groundtruth_paths_gen(self):
        groundtruth_paths = set()
        time = self.initial_state.timestamp or datetime.datetime.now()

        for _ in range(self.number_steps):
            # Random drop tracks
            groundtruth_paths.difference_update(
github dstl / Stone-Soup / stonesoup / types / prediction.py View on Github external
""" MeasurementPrediction type

    Most simple measurement prediction type, which only has time and a state
    vector.
    """


class GaussianStatePrediction(Prediction, GaussianState):
    """ GaussianStatePrediction type

    This is a simple Gaussian state prediction object, which, as the name
    suggests, is described by a Gaussian distribution.
    """


class GaussianMeasurementPrediction(MeasurementPrediction, GaussianState):
    """ GaussianMeasurementPrediction type

    This is a simple Gaussian measurement prediction object, which, as the name
    suggests, is described by a Gaussian distribution.
    """

    cross_covar = Property(CovarianceMatrix,
                           doc="The state-measurement cross covariance matrix",
                           default=None)

    def __init__(self, state_vector, covar, timestamp=None,
                 cross_covar=None, *args, **kwargs):
        if(cross_covar is not None
           and cross_covar.shape[1] != state_vector.shape[0]):
            raise ValueError("cross_covar should have the same number of \
                             columns as the number of rows in state_vector")
github dstl / Stone-Soup / stonesoup / smoother / lineargaussian.py View on Github external
t_delta = smoothed_state_tplus1.timestamp - t
        A = self.transition_model.matrix(time_interval=t_delta)

        x = filtered_state_t.mean
        V = filtered_state_t.covar
        x_predict = predicted_state_tplus1.mean
        V_predict = predicted_state_tplus1.covar
        x_tplus1 = smoothed_state_tplus1.mean
        V_tplus1 = smoothed_state_tplus1.covar

        smoother_gain = V @ A.T @ np.linalg.inv(V_predict)

        x_smoothed = x + smoother_gain@(x_tplus1 - x_predict)
        V_smoothed = V + smoother_gain@(V_tplus1 - V_predict)@smoother_gain.T

        return GaussianState(x_smoothed, V_smoothed, timestamp=t)
github dstl / Stone-Soup / stonesoup / types / state.py View on Github external
covar = Property(CovarianceMatrix, doc='Covariance matrix of state.')

    def __init__(self, state_vector, covar, *args, **kwargs):
        covar = CovarianceMatrix(covar)
        super().__init__(state_vector, covar, *args, **kwargs)
        if self.state_vector.shape[0] != self.covar.shape[0]:
            raise ValueError(
                "state vector and covar should have same dimensions")

    @property
    def mean(self):
        """The state mean, equivalent to state vector"""
        return self.state_vector


class WeightedGaussianState(GaussianState):
    """Weighted Gaussian State Type

    Gaussian State object with an associated weight.  Used as components
    for a GaussianMixtureState.
    """
    weight = Property(float, default=0, doc="Weight of the Gaussian State.")


class ParticleState(Type):
    """Particle State type

    This is a particle state object which describes the state as a
    distribution of particles"""

    timestamp = Property(datetime.datetime, default=None,
                         doc="Timestamp of the state. Default None.")
github dstl / Stone-Soup / stonesoup / initiator / simple.py View on Github external
from ..types.hypothesis import SingleHypothesis
from ..types.numeric import Probability
from ..types.particle import Particle
from ..types.state import GaussianState
from ..types.track import Track
from ..types.update import GaussianStateUpdate, ParticleStateUpdate
from ..updater.kalman import KalmanUpdater
from ..dataassociator import DataAssociator
from ..deleter import Deleter
from ..updater import Updater


class SinglePointInitiator(GaussianInitiator):
    """ SinglePointInitiator class"""

    prior_state = Property(GaussianState, doc="Prior state information")
    measurement_model = Property(MeasurementModel, doc="Measurement model")

    def initiate(self, unassociated_detections, **kwargs):
        """Initiates tracks given unassociated measurements

        Parameters
        ----------
        unassociated_detections : list of \
        :class:`stonesoup.types.detection.Detection`
            A list of unassociated detections

        Returns
        -------
        : :class:`sets.Set` of :class:`stonesoup.types.track.Track`
            A list of new tracks with an initial :class:`~.GaussianState`
        """