-
Notifications
You must be signed in to change notification settings - Fork 797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DiscreteConditional
and DiscreteBayesNet
improvements
#1781
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the mode function is not correct. The correct way to compute the mode is converting to a factor graph and calling max-product. There will be cases where they give the same result, but not in general. I think I even have a counter-example in the tests somewhere.
// Check argmax on P(C|D) and P(D) | ||
TEST(DiscreteConditional, Argmax) { | ||
DiscreteKey C(2, 2), D(4, 2); | ||
DiscreteConditional D_cond(D, "1/3"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D_prior
TEST(DiscreteConditional, Argmax) { | ||
DiscreteKey C(2, 2), D(4, 2); | ||
DiscreteConditional D_cond(D, "1/3"); | ||
DiscreteConditional C_given_DE((C | D) = "1/4 1/1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C_given_D
|
||
// Case 1: No parents | ||
size_t actual1 = D_cond.argmax(); | ||
EXPECT_LONGS_EQUAL(1, actual1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it 1? Document how tie-breaking will be handled in argmax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks for figuring it out with me.
DiscreteConditional
.DiscreteConditional::argmax
for arbitrary conditionals, not just conditionals with no parents.DiscreteLookupTable
andDiscreteConditional
.