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 ofState
.
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 fromnumpy
andscipy
, that returns aParticleState
- Parameters:
distribution_func (
Callable
) – Callable function that returns samples from the desired distribution.params (
dict
) – Dictionary containing the keyword arguments fordistribution_func
.ndim_state (
int
) – Number of dimensions in each sample.
- params: dict
Dictionary containing the keyword arguments for
distribution_func
.
- 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 isNone
.
- Returns:
particle state – The particle state containing the samples of the distribution
- Return type:
Detection
- class stonesoup.sampler.detection.DetectionSampler[source]
Bases:
Sampler
Detection sampler base class.
Samples from a continuous distribution based on provided detections.
- 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
- sample(detections)[source]
Samples from a Gaussian mixture around detections
- Parameters:
detections (
Detection
or set ofDetection
) – Detections forming the distribution to sample from. Equal component weighting is assumed.- Returns:
ParticleState
of samples.- Return type:
- 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, oneDetectionSampler
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 asample()
method.- Parameters:
detection_sampler (
DetectionSampler
) – Sampler for generating samples from detectionsbackup_sampler (
Sampler
) – Sampler for generating samples in the absence of detections
- detection_sampler: DetectionSampler
Sampler for generating samples from detections
- sample(detections, timestamp=None)[source]
Produces samples based on the detections provided.
- Parameters:
detections (
Detection
or set ofDetection
) – Detections used for generating samples.timestamp (datetime.datetime, optional) – timestamp for when the sample is made.
- Returns:
The state object returned by either of the specified samplers.
- Return type: