Skip to content

Commit 327cbc9

Browse files
authored
[ML] Impose an absolute cutoff on the minimum variance (#8)
Impose an absolute cutoff on the minimum variance based on the offset to avoid overflow when calculating lgamma values fixes #488
1 parent 952dba0 commit 327cbc9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/maths/CXMeansOnline1d.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ 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 vmin = std::min(MIN_RELATIVE_VARIANCE * std::max(v,square(offset)), MIN_ABSOLUTE_VARIANCE);
308308

309309
// Mixture of normals
310310
double wl = CBasicStatistics::count(mvl) / n;

0 commit comments

Comments
 (0)