|
|
| MixtureParams (Allocator_ const &allocator) |
| | Constructs an empty mixture that allocates through allocator.
|
| | MixtureParams (Capacity capacity, Allocator_ const &allocator={}) |
| | Constructs an empty mixture in a FixedSizeSpace that reserves room for capacity components.
|
|
| MixtureParams (Index valueDimension, Allocator_ const &allocator={}) |
| | Constructs an empty mixture whose components will have valueDimension value coordinates.
|
|
| MixtureParams (SpaceType space, Allocator_ const &allocator={}) |
| | Constructs an empty mixture in space.
|
|
| MixtureParams (SpaceType space, Capacity capacity, Allocator_ const &allocator={}) |
| | Constructs an empty mixture in space that reserves room for capacity components.
|
| | MixtureParams (SpaceType space, Index valueDimension, Allocator_ const &allocator={}) |
| | Constructs an empty mixture in space whose components will have valueDimension value coordinates.
|
| | MixtureParams (MixtureParams const &other) |
| | Copies the entries and their factorizations into storage from other's allocator, with its capacity (see Allocation).
|
|
| MixtureParams (MixtureParams const &other, Allocator_ const &allocator) |
| | Copies the entries and their factorizations into storage from allocator, with other's capacity and no lineage.
|
|
| MixtureParams (MixtureParams &&other) noexcept |
| | Takes other's entries and storage; a view of other may not be read afterward.
|
|
| MixtureParams (MixtureParams &&other, Allocator_ const &allocator) |
| | Moves other's entries into storage from allocator, taking its storage when the allocators are equal.
|
| MixtureParams & | operator= (MixtureParams const &other) |
| | Copies other's entries and space into this mixture's storage, which keeps its allocator and capacity.
|
| MixtureParams & | operator= (MixtureParams &&other) noexcept |
| | Takes other's entries, space, and lineage, and its storage when the allocators are equal or propagate; otherwise moves the entries into this mixture's storage, which keeps its capacity.
|
| allocator_type | get_allocator () const |
| Index | size () const |
| bool | empty () const |
| std::optional< Index > | capacity () const |
| void | setCapacity (Index capacity) |
| | Reserves room for capacity components, and the scratch for that many, and makes holding more a precondition violation.
|
| Index | valueDimension () const |
| Index | differenceDimension () const |
| SpaceType const & | space () const |
| void | resizeComponents (Index n) |
| | Resizes every component, and a space with one resizable block, to n value coordinates.
|
template<typename Path, typename MeanDerived, typename CovDerived, typename CrossDerived>
requires (isGaussian<ComponentType>) |
| void | insert (Index element, Eigen::MatrixBase< MeanDerived > const &mean, Eigen::MatrixBase< CovDerived > const &cov, Eigen::MatrixBase< CrossDerived > const &cross) |
| | Inserts the entries mean into the resizable block named by the tag path Path of every component, before its element element, with covariance cov and cross-covariance cross with each component's existing entries.
|
template<typename Path, typename MeanDerived, typename CovDerived>
requires (isGaussian<ComponentType>) |
| void | insert (Index element, Eigen::MatrixBase< MeanDerived > const &mean, Eigen::MatrixBase< CovDerived > const &cov) |
| | insert() of entries independent of the existing ones.
|
template<typename Path>
requires (isGaussian<ComponentType>) |
| void | erase (Index element, Index count=1) |
| | Removes count elements of the resizable block named by the tag path Path from every component, starting at its element element.
|
|
void | reserve (Index n) |
| | Reserves room for n components without setting a capacity.
|
|
void | clear () |
| | Removes every component; the space, capacity, scratch, and lineage's mark stay.
|
| void | swap (MixtureParams &other) |
| | Exchanges the entries, space, and lineage with other, which must come from an equal allocator.
|
| LineageType const & | lineage () const |
| void | startLineage () |
| | Makes the current components the parents of the lineage, each its own, and counts the mark.
|
| const_iterator | begin () const |
| const_iterator | end () const |
| Entry const & | operator[] (Index i) const |
| Index | add (Scalar logWeight, ComponentType component) |
| | Appends component, which must be in the mixture's space, with log-weight logWeight, and no parent in the lineage.
|
| Index | add (Scalar logWeight, MomentsType moments) |
| | Appends the Gaussian with moments.
|
template<MatrixExpression Mean, MatrixExpression Cov>
requires (isGaussian<ComponentType>) |
| Index | add (Scalar logWeight, Mean &&mean, Cov &&cov) |
| | add() of the Gaussian with mean mean and covariance cov, moving either one passed as an rvalue of the stored type.
|
|
void | remove (Index i) |
| | Removes entry i by moving the last entry into its place.
|
|
void | setComponent (Index i, ComponentType component) |
| | Replaces component i with component, which must be in the mixture's space.
|
|
void | setMoments (Index i, MomentsType moments) |
| | Sets the mean and covariance of Gaussian i to moments.
|
template<MatrixExpression Mean>
requires (isGaussian<ComponentType>) |
| void | setMean (Index i, Mean &&mean) |
| | Sets the mean of Gaussian i; see GaussianParams::setMean().
|
template<MatrixExpression Cov>
requires (isGaussian<ComponentType>) |
| void | setCovariance (Index i, Cov &&cov) |
| | Sets the covariance of Gaussian i; see GaussianParams::setCovariance().
|
|
void | setLogWeight (Index i, Scalar logWeight) |
| | Sets the log-weight of entry i.
|
|
void | scaleWeight (Index i, Scalar logScale) |
| | Multiplies the weight of entry i by \( e^{\mathrm{logScale}} \).
|
|
void | scaleWeights (Scalar logScale) |
| | Multiplies every weight by \( e^{\mathrm{logScale}} \).
|
| std::expected< Scalar, WeightError > | logTotalWeight () const |
| std::expected< void, WeightError > | normalize () |
| | Scales the weights so they sum to one.
|
| std::expected< Scalar, WeightError > | ess () const |
| Index | mostProbable () const |
| template<std::ranges::input_range R> |
| void | assign (R &&components) |
| | Replaces the components with those in components, a range of (log-weight, component) pairs, or of (log-weight, moments) pairs for Gaussian components, or other structured-bindable pairs, such as uniformComponents()'s.
|
|
void | append (MixtureParams const &other) |
| | Appends copies of other's entries, which must be in the same space, with no parent in the lineage.
|
| template<typename F> |
| void | forEach (F &&f) |
| | Calls f on each entry as a MutableEntry&, returning nothing; reweight() takes one that returns a log scale factor.
|
| template<ExecutionPolicy P, typename F> |
| void | forEach (P &&policy, F &&f) |
| | forEach() under policy, a for-each over the entries (see Execution policies).
|
|
template<typename F> |
| void | reweight (F &&f) |
| | Calls f on each entry as a MutableEntry&, as forEach() does, and adds what it returns, a log scale factor in a floating-point type, to that entry's log-weight.
|
|
template<ExecutionPolicy P, typename F> |
| void | reweight (P &&policy, F &&f) |
| | reweight() under policy, as forEach() under it runs.
|
| Index | merge (Index keep, Index absorb) |
| | Merges absorb into keep.
|
| ComponentType | merged (Index first, Index second) const |
| Index | merge (Index keep, Index absorb, ComponentType component) |
| | Merges absorb into keep.
|
| Index | merge (Index keep, Index absorb, MomentsType moments) |
| | Merges absorb into keep.
|
| template<std::ranges::forward_range R> |
| void | split (Index i, R &&children) |
| | Replaces component i with children.
|
template<bool ReturnRemovedWeight = false, typename Pred>
requires (!ReturnRemovedWeight) |
| void | removeIf (Pred pred) |
| | Removes every entry for which pred(Entry const &), or pred(Index, Entry const &) with the entry's position, is true.
|
template<bool ReturnRemovedWeight, typename Pred>
requires ReturnRemovedWeight |
| std::expected< Scalar, WeightError > | removeIf (Pred pred) |
| | As above, returning the log of the removed fraction of the total weight, or the WeightError that left the mixture unchanged.
|
| std::expected< Scalar, WeightError > | pruneBelow (Scalar logThreshold) |
| | Removes every component whose normalized log-weight is below logThreshold, and normalizes the weights of the rest; the most probable component is always kept, the first of them if several are.
|
| std::expected< Scalar, WeightError > | pruneTail (Scalar logFraction) |
| | Removes the lightest components, as many as can be while their combined normalized weight stays below \( e^{\mathrm{logFraction}} \), and normalizes the weights of the rest.
|
| std::expected< Scalar, WeightError > | pruneToSize (Index maxSize) |
| | Removes the lightest components until at most maxSize, at least one, remain, and normalizes the weights of the rest.
|
| template<typename Path> |
| auto | marginal () const & |
|
template<typename Path> |
| void | marginal () const &&=delete |
| | A marginal of a temporary would outlive it.
|
|
template<typename Path> |
| auto | marginal (Index element) const & |
| | marginal() of one repetition of a repeated block; see GaussianParams::marginal(element).
|
|
template<typename Path> |
| void | marginal (Index element) const &&=delete |
| | A marginal of a temporary would outlive it.
|
template<typename GivenPath, typename Derived>
requires (isGaussian<ComponentType>) |
| auto | conditional (Eigen::MatrixBase< Derived > const &values) const |
| std::expected< void, MixtureError > | factorize () const |
| | Validates the weights and factorizes every component that has changed.
|
| template<typename R> |
| std::expected< void, MixtureError > | factorize (R const &repair) |
| | factorize(), repairing each covariance that is not positive definite by repair (see GaussianParams::factorize(R const &)): m.factorize(roots::ridge()).
|
| std::expected< DensityType, MixtureError > | toDensity () const & |
| | Factorizes as needed (see factorize()).
|
|
void | toDensity () const &&=delete |
| | A density of a temporary would outlive it.
|
| template<typename R> |
| std::expected< DensityType, MixtureError > | toDensity (R const &repair) & |
| | toDensity(), repairing covariances that are not positive definite by repair (see factorize(R const &)): m.toDensity(roots::ridge()).
|
|
template<typename R> |
| void | toDensity (R const &) &&=delete |
| | A density of a temporary would outlive it.
|
template<internal::ComponentOrInfoForm Component_, typename Allocator_ = DefaultAllocator>
class Emrys::MixtureParams< Component_, Allocator_ >
A weighted sum of components of one type, all in one space.
A mixture model with unnormalized weights. Each entry has a log-weight and a component (see Component): a Gaussian, which makes the mixture a Gaussian mixture, GaussianMixtureParams; or a Hybrid, which makes it a mixture of hybrid states, the state of a mixture of interacting multiple model filters (decisions.md [component-first], [filters-and-recursions]). Weights need not be normalized; a log-weight of -inf is a zero weight. All components share the mixture's space, and so its valueDimension() and differenceDimension().
Entries are read by index, mixture[i], or in order through const iterators, and changed only through this object's methods, which take an entry's index, as a ParticleSet's do (decisions.md [mixture-entries]). Adding keeps every index and may invalidate every iterator; removal moves the last entry into the gap, so an index is held only while nothing is removed.
toDensity() validates the weights, factorizes every component that has changed, and returns a Mixture, which checks this object for changes: reading it after this object has changed in any way is a programmer error caught by EMRYS_FILTER_ASSERT (decisions.md [view-stamp]). So is changing the mixture from inside a forEach() or removeIf() callback.
What only a Gaussian has is offered for Gaussian components alone, and a mixture of other components says so at the call: the members that take or give a component's moments (add() of moments, setMoments(), setMean(), setCovariance(), merge() with moments, insert(), erase(), and resizeComponents()), the marginal() and conditional() views, and sampling. Every mixture adds and replaces whole components, collapses a pair with merge(keep, absorb), and reweights, truncates, and removes.
marginal() returns a read-only view of a subset of every component's entries, which checks only this object's size and structure: values and weights may change under it, but reading it after components are added, removed, or resized, or this object is assigned to, is a programmer error. Neither view may outlive this object, and neither may be made from a temporary.
Every component shares the mixture's space (see Spaces): component means are normalized when set, and moments() averages in the space's tangent space.
The entries, and the scratch that pruneTail() and pruneToSize() use, come from the allocator (see Allocation). A mixture given a Capacity reserves room for that many components once; holding more is a precondition violation.
- Template Parameters
-
| Component_ | the components' type (see Component), which sets their space, scalar, dimensions, and storage bounds |
| Allocator_ | allocator for the entries and scratch (see Allocation) |
- See also
- class Mixture, GaussianMixtureParams, class GaussianParams, class Hybrid