Skip to content

Commit 9dcf3ed

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 7d78269 commit 9dcf3ed

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
@@ -304,7 +304,8 @@ void BICGain(maths_t::EDataType dataType,
304304
double a = pow2(m + gammaOffset) / v;
305305
double b = (m + gammaOffset) / v;
306306

307-
double vmin = std::min(MIN_RELATIVE_VARIANCE * v, MIN_ABSOLUTE_VARIANCE);
307+
double smin = std::max(logNormalOffset, gammaOffset);
308+
double vmin = std::min(MIN_RELATIVE_VARIANCE * std::max(v, pow2(smin)), MIN_ABSOLUTE_VARIANCE);
308309

309310
// Mixture of normals
310311
double wl = CBasicStatistics::count(mvl) / n;

0 commit comments

Comments
 (0)