Skip to content
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

Merged
merged 22 commits into from
Jul 22, 2024

Conversation

varunagrawal
Copy link
Collaborator

@varunagrawal varunagrawal commented Jul 11, 2024

  1. New constructor for DiscreteConditional.
  2. DiscreteConditional::argmax for arbitrary conditionals, not just conditionals with no parents.
  3. Merge DiscreteLookupTable and DiscreteConditional.
  4. Unit tests.

@varunagrawal varunagrawal requested a review from dellaert July 11, 2024 04:18
@varunagrawal varunagrawal self-assigned this Jul 11, 2024
Copy link
Member

@dellaert dellaert left a 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");
Copy link
Member

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");
Copy link
Member

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);
Copy link
Member

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

@varunagrawal varunagrawal requested a review from dellaert July 21, 2024 15:48
Copy link
Member

@dellaert dellaert left a 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.

@varunagrawal varunagrawal merged commit feab2a2 into develop Jul 22, 2024
31 checks passed
@varunagrawal varunagrawal deleted the discrete-improv branch July 22, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants