Skip to content

Commit 67514fb

Browse files
tveaseyedsavage
authored andcommitted
[ML] Impose a cutoff on the minimum variance.
To avoid overflow when calculating lgamma values an absolute cutoff on the minimum variance must be set. Fixes #488
1 parent 3f75671 commit 67514fb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/maths/CXMeansOnline1d.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ void BICGain(maths_t::EDataType dataType,
295295
double a = pow2(m + gammaOffset) / v;
296296
double b = (m + gammaOffset) / v;
297297

298-
double vmin = std::min(MIN_RELATIVE_VARIANCE * v, MIN_ABSOLUTE_VARIANCE);
298+
double smin = std::max(logNormalOffset, gammaOffset);
299+
double vmin = std::min(MIN_RELATIVE_VARIANCE * std::max(v, pow2(smin)), MIN_ABSOLUTE_VARIANCE);
299300

300301
// Mixture of normals
301302
double wl = CBasicStatistics::count(mvl) / n;

0 commit comments

Comments
 (0)