MarineRoboticsGroup / dcsam

Factored inference for discrete-continuous smoothing and mapping.
https://arxiv.org/abs/2204.11936
MIT License
144 stars 18 forks source link

Potential numerical issues in DCFactor exp-normalization #6

Closed keevindoherty closed 3 years ago

keevindoherty commented 3 years ago

The DCFactor::evalProbs( ...) function implements "exp-normalization" where we attempt to normalize a set of (negative) log probabilities as exp(log p_i) / ( sum_i exp(log p_i) ). For exceptionally small values of log p_i, e.g. -10^6, this expression is susceptible to underflow. This can occur, for example, if the "continuous part" of a DCFactor for a particular discrete assignment has large error, even independent of the "discrete part." Rather than compute this expression naively as written, we should "shift" the exponents prior to normalizing to avoid numerical issues.

cc: @kurransingh