Changed the add_probability() method of joint_probability_table so

it does a saturating add rather than a normal add.  This ensures the
probability value stays exactly <= 1.  Previously, floating point
rounding error could cause it to be slightly above 1 and would therefore
cause some asserts to misfire during debugging mode.
This commit is contained in:
Davis King 2011-12-10 11:38:05 -05:00
parent 10829e4d69
commit cbcb80bfd2
2 changed files with 4 additions and 1 deletions

View File

@ -333,6 +333,8 @@ namespace dlib
if (table.is_in_domain(a))
{
table[a] += p;
if (table[a] > 1.0)
table[a] = 1.0;
}
else
{

View File

@ -294,7 +294,8 @@ namespace dlib
- #size() == size() + 1
- #probability(a) == p
- else
- #probability(a) == probability(a) + p
- #probability(a) == min(probability(a) + p, 1.0)
(i.e. does a saturating add)
- #has_entry_for(a) == true
!*/