EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Mixture.h File Reference

The mixture: the parameters MixtureParams of weighted components of one type (decisions.md [component-first], [params-and-density]), with its components added, removed, merged, split, truncated, and reweighted, and the MixtureLineage it keeps through those for the mixture smoother [smoothing]; the Mixture that evaluates the density, read from them by toDensity(); the MixtureMarginal view from marginal<Path>(), a range over the components' marginals [element-marginals], which a Hybrid's marginal is too; the draws from a mixture of Gaussians; and the GaussianMixtureParams and GaussianMixture aliases for the mixture of Gaussians, the spelling for the common case. More...

#include <algorithm>
#include <concepts>
#include <expected>
#include <functional>
#include <iterator>
#include <random>
#include <span>
#include <numeric>
#include <optional>
#include <ranges>
#include <type_traits>
#include <utility>
#include <variant>
#include <vector>
#include <EmrysFilter/Core/Allocation.h>
#include <EmrysFilter/Core/Execution.h>
#include <EmrysFilter/Core/Forwarding.h>
#include <EmrysFilter/Core/Macros.h>
#include <EmrysFilter/Core/Math.h>
#include <EmrysFilter/Core/Multiply.h>
#include <EmrysFilter/Core/Print.h>
#include <EmrysFilter/Core/Resampling.h>
#include <EmrysFilter/Core/Solve.h>
#include <EmrysFilter/Core/Stamp.h>
#include <EmrysFilter/Core/Weights.h>
#include <EmrysFilter/Distributions/Component.h>
#include <EmrysFilter/Distributions/Gaussian.h>
#include <EmrysFilter/Distributions/Moments.h>
#include <EmrysFilter/Distributions/SampleSet.h>
#include <EmrysFilter/Distributions/Sampling.h>
#include <EmrysFilter/Distributions/Statistics.h>
#include <EmrysFilter/Spaces/Composite.h>
#include <EmrysFilter/Spaces/Indexing.h>
#include <EmrysFilter/Spaces/Space.h>
#include <EmrysFilter/Spaces/Subspace.h>

Go to the source code of this file.

Classes

struct  Emrys::ComponentError
 A mixture component that could not be factorized. More...
class  Emrys::MixtureLineage< Scalar_, Allocator_ >
 How each component of a Mixture descends from the components it had at its last startLineage(): each component's share from each of those parents. More...
class  Emrys::MixtureParams< Component_, Allocator_ >
 A weighted sum of components of one type, all in one space. More...
struct  Emrys::MixtureParams< Component_, Allocator_ >::Entry
 One weighted component. More...
class  Emrys::MixtureParams< Component_, Allocator_ >::MutableEntry
 Writable access to one entry during forEach(). More...
class  Emrys::Mixture< Component_, Allocator_ >
 The density of a Mixture whose components have been factorized: a read-only view. More...
class  Emrys::MixtureMarginal< Source, Selection, SubSpace >
 Read-only view of a subset of the coordinates of every component of a mixture or a hybrid, which iterates the components and gives each one's marginal in turn (decisions.md [element-marginals]). More...
struct  Emrys::MixtureMarginal< Source, Selection, SubSpace >::Element
 One component's log-weight, as in the source, and its marginal. More...

Typedefs

using Emrys::MixtureError = std::variant<WeightError, ComponentError>
 Reasons MixtureParams::toDensity() can fail.
using Emrys::GaussianMixtureError = MixtureError
 MixtureError by the name it had when every mixture was a GaussianMixtureParams.
template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
using Emrys::GaussianMixtureParams = MixtureParams<Gaussian<Space_, Scalar_>, Allocator_>
 A Mixture of Gaussians in covariance form, the spelling for the common case (decisions.md [component-first]): \( \sum_i w_i \, \mathcal{N}(x; \mu_i, \Sigma_i) \).
template<Space Space_, RealScalar Scalar_ = double, typename Allocator_ = DefaultAllocator>
using Emrys::GaussianMixture = Mixture<Gaussian<Space_, Scalar_>, Allocator_>
 The Mixture of a GaussianMixtureParams, the spelling for the common case (decisions.md [component-first]).

Functions

template<typename Scalar, typename Space, typename Allocator, std::uniform_random_bit_generator G, typename R = resamplers::Multinomial>
requires Resampler<R, Scalar, G>
SampleSet< Space, Scalar > Emrys::drawSamples (Mixture< Gaussian< Space, Scalar >, Allocator > const &mixture, Eigen::Index n, G &rng, R const &resampler={})
template<typename Scalar, typename Space, typename Allocator, std::uniform_random_bit_generator G>
Moments< Space, Scalar >::VectorType Emrys::drawSample (Mixture< Gaussian< Space, Scalar >, Allocator > const &mixture, G &rng)
template<typename Scalar, typename Space, typename Allocator, std::uniform_random_bit_generator G, typename R = resamplers::Multinomial>
requires Resampler<R, Scalar, G>
SamplesWithLogDensity< Space, Scalar > Emrys::drawSamplesWithLogDensity (Mixture< Gaussian< Space, Scalar >, Allocator > const &mixture, Eigen::Index n, G &rng, R const &resampler={})
template<ExecutionPolicy P, typename Scalar, typename Space, typename Allocator, std::uniform_random_bit_generator G, typename R = resamplers::Multinomial>
requires Resampler<R, Scalar, G>
SamplesWithLogDensity< Space, Scalar > Emrys::drawSamplesWithLogDensity (P &&policy, Mixture< Gaussian< Space, Scalar >, Allocator > const &mixture, Eigen::Index n, G &rng, R const &resampler={})
 drawSamplesWithLogDensity() under policy: the draws are taken as the sequential form takes them, and their log-densities are a for-each over the draws (see Execution policies), so the result is Sequential's.
template<typename Scalar, typename Space, typename Allocator, std::uniform_random_bit_generator G>
SampleWithLogDensity< Space, Scalar > Emrys::drawSampleWithLogDensity (Mixture< Gaussian< Space, Scalar >, Allocator > const &mixture, G &rng)

Detailed Description

The mixture: the parameters MixtureParams of weighted components of one type (decisions.md [component-first], [params-and-density]), with its components added, removed, merged, split, truncated, and reweighted, and the MixtureLineage it keeps through those for the mixture smoother [smoothing]; the Mixture that evaluates the density, read from them by toDensity(); the MixtureMarginal view from marginal<Path>(), a range over the components' marginals [element-marginals], which a Hybrid's marginal is too; the draws from a mixture of Gaussians; and the GaussianMixtureParams and GaussianMixture aliases for the mixture of Gaussians, the spelling for the common case.

The mixture filter's state [mixture-filter], [filters-and-recursions] and mixture measurement noise [additive-noise] are mixtures. Read UniformMixture.h next.