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

Log-weights: the WeightError a normalization can fail with (NumericError.h), and the streaming log-sum-exp that totals them without overflow, sequentially or in chunks under an execution policy: LogSumExp and logSumExp(), which are public, so that a user's code normalizes weights or sums likelihoods as the library does. More...

#include <algorithm>
#include <concepts>
#include <expected>
#include <limits>
#include <random>
#include <ranges>
#include <span>
#include <EmrysFilter/Core/Execution.h>
#include <EmrysFilter/Core/Macros.h>
#include <EmrysFilter/Core/Math.h>
#include <EmrysFilter/Core/NumericError.h>

Go to the source code of this file.

Classes

class  Emrys::LogSumExp< Scalar >
 Streaming log-sum-exp: accumulates \( \log \sum_i e^{x_i} \) without overflow. More...

Functions

template<typename Scalar, ExecutionPolicy P, typename LogAt>
Scalar Emrys::logSumExp (P &&policy, Eigen::Index count, LogAt const &logAt)
template<typename Scalar, typename LogAt>
Scalar Emrys::logSumExp (Eigen::Index count, LogAt const &logAt)
 logSumExp(policy, count, logAt) under execution::sequential.
template<ExecutionPolicy P, typename Derived>
Derived::Scalar Emrys::logSumExp (P &&policy, Eigen::ArrayBase< Derived > const &logs)
template<typename Derived>
Derived::Scalar Emrys::logSumExp (Eigen::ArrayBase< Derived > const &logs)
 logSumExp(policy, logs) under execution::sequential.

Detailed Description

Log-weights: the WeightError a normalization can fail with (NumericError.h), and the streaming log-sum-exp that totals them without overflow, sequentially or in chunks under an execution policy: LogSumExp and logSumExp(), which are public, so that a user's code normalizes weights or sums likelihoods as the library does.

Every distribution with weighted elements (GaussianMixtureParams, ParticleSet, Categorical) normalizes through internal::logTotalWeight(), and a single draw of one of them takes internal::drawIndex(). The states whose elements can be pruned (ParticleSet, ParticleGaussianParams, MixtureParams, GridGaussianParams) choose what pruneBelow(), pruneTail(), and pruneToSize() remove through the same rules, internal::PruneBelowRule, internal::PruneTailRule, and internal::PruneToSizeRule, so ties are broken alike. Read Resampling.h next.