Sampler

class stonesoup.sampler.base.Sampler[source]

Bases: Base

Sampler base class

A sampler is used to generate samples from a probability distribution specified by the user. This class is provided to allow any set of samples to be generated from any specified distribution. A Sampler should return sub-types of State.

Particle

class stonesoup.sampler.particle.ParticleSampler(distribution_func: Callable, params: dict, ndim_state: int)[source]

Bases: Sampler

Particle sampler.

A generic Sampler which wraps around most distribution sampling functions from numpy and scipy, that returns a ParticleState

Parameters:
  • distribution_func (Callable) – Callable function that returns samples from the desired distribution.

  • params (dict) – Dictionary containing the keyword arguments for distribution_func.

  • ndim_state (int) – Number of dimensions in each sample.

distribution_func: Callable

Callable function that returns samples from the desired distribution.

params: dict

Dictionary containing the keyword arguments for distribution_func.

ndim_state: int

Number of dimensions in each sample.

sample(params=None, timestamp=None)[source]

Samples from the desired distribution and returns as a ParticleState

Parameters:
  • params (dict, optional) – Keyword arguments for distribution_func. These parameters will update the parameters specified in the class properties and can either be completely redefined or the subset of parameters that need changing.

  • timestamp (datetime.datetime, optional) – Timestamp for the returned ParticleState. Default is None.

Returns:

particle state – The particle state containing the samples of the distribution

Return type:

ParticleState

Detection

class stonesoup.sampler.detection.DetectionSampler[source]

Bases: Sampler

Detection sampler base class.

Samples from a continuous distribution based on provided detections.

abstract sample(detections)[source]

Sample from continuous distribution based on detections

Parameters:

detections (set of Detection) – Detections used to describe the distribution

Return type:

State

class stonesoup.sampler.detection.GaussianDetectionParticleSampler(nsamples: int = 1)[source]

Bases: DetectionSampler

Particle sampler using Gaussian detections to initialise the distribution.

Particle sampler that is preloaded with the gm_sample() method for sampling from Gaussian mixture distributions. This class can handle one or more linear and non-linear Gaussian detections and will either return samples from a single or mixture of Gaussians depending on which is provided.

Parameters:

nsamples (int, optional) – Number of samples to return

nsamples: int

Number of samples to return

sample(detections)[source]

Samples from a Gaussian mixture around detections

Parameters:

detections (Detection or set of Detection) – Detections forming the distribution to sample from. Equal component weighting is assumed.

Returns:

ParticleState of samples.

Return type:

ParticleState

class stonesoup.sampler.detection.SwitchingDetectionSampler(detection_sampler: DetectionSampler, backup_sampler: Sampler)[source]

Bases: DetectionSampler

Redundant detection sampler class.

Redundant detection sampler accepts two Sampler objects, one DetectionSampler and one to fall back on when detections are not available. The samples returned depend on which samplers have been specified. Both samplers must have a sample() method.

Parameters:
  • detection_sampler (DetectionSampler) – Sampler for generating samples from detections

  • backup_sampler (Sampler) – Sampler for generating samples in the absence of detections

detection_sampler: DetectionSampler

Sampler for generating samples from detections

backup_sampler: Sampler

Sampler for generating samples in the absence of detections

sample(detections, timestamp=None)[source]

Produces samples based on the detections provided.

Parameters:
Returns:

The state object returned by either of the specified samplers.

Return type:

State