Struggling with Bayes network











up vote
0
down vote

favorite












enter image description here



Im in a machine learning course and bayes networks was presented in such an abstract way I find it really difficult to understand how to use it. And all examples I can find, the final numbers seem appear magically without any explanation. Please help!



I am stuck already at problem 1. I think some of the idea is that $G$ is not going to be a part of the simplified expression because it's not on the path from $B$ to $W$ in the graph (DAG).



I want use Bayes formula:



$$
P(B = tr | W = tr) = dfrac{P(B = tr, W = tr)}{P(W = tr)}
$$



But I dont know how to continue from there, or expand this expression rather.



I guess if I understand 1, 2 is gonna be easier. Either way Im happy with any help I get. Thanks










share|cite|improve this question




























    up vote
    0
    down vote

    favorite












    enter image description here



    Im in a machine learning course and bayes networks was presented in such an abstract way I find it really difficult to understand how to use it. And all examples I can find, the final numbers seem appear magically without any explanation. Please help!



    I am stuck already at problem 1. I think some of the idea is that $G$ is not going to be a part of the simplified expression because it's not on the path from $B$ to $W$ in the graph (DAG).



    I want use Bayes formula:



    $$
    P(B = tr | W = tr) = dfrac{P(B = tr, W = tr)}{P(W = tr)}
    $$



    But I dont know how to continue from there, or expand this expression rather.



    I guess if I understand 1, 2 is gonna be easier. Either way Im happy with any help I get. Thanks










    share|cite|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      enter image description here



      Im in a machine learning course and bayes networks was presented in such an abstract way I find it really difficult to understand how to use it. And all examples I can find, the final numbers seem appear magically without any explanation. Please help!



      I am stuck already at problem 1. I think some of the idea is that $G$ is not going to be a part of the simplified expression because it's not on the path from $B$ to $W$ in the graph (DAG).



      I want use Bayes formula:



      $$
      P(B = tr | W = tr) = dfrac{P(B = tr, W = tr)}{P(W = tr)}
      $$



      But I dont know how to continue from there, or expand this expression rather.



      I guess if I understand 1, 2 is gonna be easier. Either way Im happy with any help I get. Thanks










      share|cite|improve this question















      enter image description here



      Im in a machine learning course and bayes networks was presented in such an abstract way I find it really difficult to understand how to use it. And all examples I can find, the final numbers seem appear magically without any explanation. Please help!



      I am stuck already at problem 1. I think some of the idea is that $G$ is not going to be a part of the simplified expression because it's not on the path from $B$ to $W$ in the graph (DAG).



      I want use Bayes formula:



      $$
      P(B = tr | W = tr) = dfrac{P(B = tr, W = tr)}{P(W = tr)}
      $$



      But I dont know how to continue from there, or expand this expression rather.



      I guess if I understand 1, 2 is gonna be easier. Either way Im happy with any help I get. Thanks







      probability statistics machine-learning bayes-theorem bayesian-network






      share|cite|improve this question















      share|cite|improve this question













      share|cite|improve this question




      share|cite|improve this question








      edited Nov 24 at 0:55









      Bernard

      116k637108




      116k637108










      asked Nov 24 at 0:53









      Amoz

      1949




      1949






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Firstly, I'm going to change notation, so that $W$ is ${W = tr}$ and $W^prime$ is the converse.



          We know that the events $B, W$ are conditionally independent given the alarm, so we want to think about the probability of both events for the possible states that the alarm can be in. We can calculate the numerator in your expression as $$P(B, W) = P(B, W, A) + P(B, W, A^prime).$$
          Now we want to convert this into probabilities that we know. The only marginal that we already know is $P(B)$ (and $P(B^prime)$), so we'll start by conditioning on $B$:
          $$P(B, W) = P(A, W | B) P(B) + P(A^prime, W | B) P(B).$$
          Due to the structure of the Bayes network we know that
          $$P(W | A, B) = P(W | A)$$
          because Watson's state depends on the state of the alarm, not on what triggered it. Conditioning again, we get
          $$P(A, W | B) = frac{P(A, W, B)}{P(B)} = frac{P(A, W, B)}{P(A, B)} frac{P(A, B)}{P(B)} = P(W | A, B) P(A | B) = P(W | A) P(A | B)$$
          and similarly
          $$P(A^prime, W | B) = P(W | A^prime) P(A^prime | B).$$
          Putting this together, we get
          $$P(B, W) = P(W | A) P(A | B) P(B) + P(W | A^prime) P(A^prime | B) P(B). \ = 0.9 cdot 0.99 cdot 0.01 + 0.5 cdot (1 - 0.99) cdot 0.01 \
          = 0.00891 + 0.00005 = 0.00896.$$



          To calculate $P(W)$ we would like to be able to use $A$ again and do the following direct calculation:
          $$P(W) = P(W, A) + P(W, A^prime) = P(W | A) P(A) + P(W | A^prime) P(A^prime)$$
          but unfortunately we don't know the marginal probabilities $P(A)$ or $P(A^prime)$, so we have to calculate them from the marginal probability that we do know, $P(B)$:
          $$P(A) = P(A, B) + P(A, B^prime) \= P(A | B) P(B) + P(A | B^prime) P(B^prime) \
          = 0.99 cdot 0.01 + 0.05 cdot (1 - 0.01) \ = 0.0099 + 0.0495 = 0.0594$$

          So $P(A) = 0.0594$ and $P(A^prime) = 1 - P(A) = 0.9406$.
          We can then calculate $P(W)$ as:
          $$P(W) = 0.9 cdot 0.0594 + 0.5 cdot 0.9406 = 0.52376.$$
          Finally,
          $$P(B | W) = frac{P(B, W)}{P(W)} = frac{0.00896}{0.52376} approx 0.0171.$$






          share|cite|improve this answer























          • thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
            – Amoz
            Nov 25 at 15:49












          • That was a mistake - thanks for spotting it. I've corrected my answer
            – Alex
            Nov 26 at 13:29











          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "69"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3011040%2fstruggling-with-bayes-network%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          Firstly, I'm going to change notation, so that $W$ is ${W = tr}$ and $W^prime$ is the converse.



          We know that the events $B, W$ are conditionally independent given the alarm, so we want to think about the probability of both events for the possible states that the alarm can be in. We can calculate the numerator in your expression as $$P(B, W) = P(B, W, A) + P(B, W, A^prime).$$
          Now we want to convert this into probabilities that we know. The only marginal that we already know is $P(B)$ (and $P(B^prime)$), so we'll start by conditioning on $B$:
          $$P(B, W) = P(A, W | B) P(B) + P(A^prime, W | B) P(B).$$
          Due to the structure of the Bayes network we know that
          $$P(W | A, B) = P(W | A)$$
          because Watson's state depends on the state of the alarm, not on what triggered it. Conditioning again, we get
          $$P(A, W | B) = frac{P(A, W, B)}{P(B)} = frac{P(A, W, B)}{P(A, B)} frac{P(A, B)}{P(B)} = P(W | A, B) P(A | B) = P(W | A) P(A | B)$$
          and similarly
          $$P(A^prime, W | B) = P(W | A^prime) P(A^prime | B).$$
          Putting this together, we get
          $$P(B, W) = P(W | A) P(A | B) P(B) + P(W | A^prime) P(A^prime | B) P(B). \ = 0.9 cdot 0.99 cdot 0.01 + 0.5 cdot (1 - 0.99) cdot 0.01 \
          = 0.00891 + 0.00005 = 0.00896.$$



          To calculate $P(W)$ we would like to be able to use $A$ again and do the following direct calculation:
          $$P(W) = P(W, A) + P(W, A^prime) = P(W | A) P(A) + P(W | A^prime) P(A^prime)$$
          but unfortunately we don't know the marginal probabilities $P(A)$ or $P(A^prime)$, so we have to calculate them from the marginal probability that we do know, $P(B)$:
          $$P(A) = P(A, B) + P(A, B^prime) \= P(A | B) P(B) + P(A | B^prime) P(B^prime) \
          = 0.99 cdot 0.01 + 0.05 cdot (1 - 0.01) \ = 0.0099 + 0.0495 = 0.0594$$

          So $P(A) = 0.0594$ and $P(A^prime) = 1 - P(A) = 0.9406$.
          We can then calculate $P(W)$ as:
          $$P(W) = 0.9 cdot 0.0594 + 0.5 cdot 0.9406 = 0.52376.$$
          Finally,
          $$P(B | W) = frac{P(B, W)}{P(W)} = frac{0.00896}{0.52376} approx 0.0171.$$






          share|cite|improve this answer























          • thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
            – Amoz
            Nov 25 at 15:49












          • That was a mistake - thanks for spotting it. I've corrected my answer
            – Alex
            Nov 26 at 13:29















          up vote
          1
          down vote



          accepted










          Firstly, I'm going to change notation, so that $W$ is ${W = tr}$ and $W^prime$ is the converse.



          We know that the events $B, W$ are conditionally independent given the alarm, so we want to think about the probability of both events for the possible states that the alarm can be in. We can calculate the numerator in your expression as $$P(B, W) = P(B, W, A) + P(B, W, A^prime).$$
          Now we want to convert this into probabilities that we know. The only marginal that we already know is $P(B)$ (and $P(B^prime)$), so we'll start by conditioning on $B$:
          $$P(B, W) = P(A, W | B) P(B) + P(A^prime, W | B) P(B).$$
          Due to the structure of the Bayes network we know that
          $$P(W | A, B) = P(W | A)$$
          because Watson's state depends on the state of the alarm, not on what triggered it. Conditioning again, we get
          $$P(A, W | B) = frac{P(A, W, B)}{P(B)} = frac{P(A, W, B)}{P(A, B)} frac{P(A, B)}{P(B)} = P(W | A, B) P(A | B) = P(W | A) P(A | B)$$
          and similarly
          $$P(A^prime, W | B) = P(W | A^prime) P(A^prime | B).$$
          Putting this together, we get
          $$P(B, W) = P(W | A) P(A | B) P(B) + P(W | A^prime) P(A^prime | B) P(B). \ = 0.9 cdot 0.99 cdot 0.01 + 0.5 cdot (1 - 0.99) cdot 0.01 \
          = 0.00891 + 0.00005 = 0.00896.$$



          To calculate $P(W)$ we would like to be able to use $A$ again and do the following direct calculation:
          $$P(W) = P(W, A) + P(W, A^prime) = P(W | A) P(A) + P(W | A^prime) P(A^prime)$$
          but unfortunately we don't know the marginal probabilities $P(A)$ or $P(A^prime)$, so we have to calculate them from the marginal probability that we do know, $P(B)$:
          $$P(A) = P(A, B) + P(A, B^prime) \= P(A | B) P(B) + P(A | B^prime) P(B^prime) \
          = 0.99 cdot 0.01 + 0.05 cdot (1 - 0.01) \ = 0.0099 + 0.0495 = 0.0594$$

          So $P(A) = 0.0594$ and $P(A^prime) = 1 - P(A) = 0.9406$.
          We can then calculate $P(W)$ as:
          $$P(W) = 0.9 cdot 0.0594 + 0.5 cdot 0.9406 = 0.52376.$$
          Finally,
          $$P(B | W) = frac{P(B, W)}{P(W)} = frac{0.00896}{0.52376} approx 0.0171.$$






          share|cite|improve this answer























          • thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
            – Amoz
            Nov 25 at 15:49












          • That was a mistake - thanks for spotting it. I've corrected my answer
            – Alex
            Nov 26 at 13:29













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          Firstly, I'm going to change notation, so that $W$ is ${W = tr}$ and $W^prime$ is the converse.



          We know that the events $B, W$ are conditionally independent given the alarm, so we want to think about the probability of both events for the possible states that the alarm can be in. We can calculate the numerator in your expression as $$P(B, W) = P(B, W, A) + P(B, W, A^prime).$$
          Now we want to convert this into probabilities that we know. The only marginal that we already know is $P(B)$ (and $P(B^prime)$), so we'll start by conditioning on $B$:
          $$P(B, W) = P(A, W | B) P(B) + P(A^prime, W | B) P(B).$$
          Due to the structure of the Bayes network we know that
          $$P(W | A, B) = P(W | A)$$
          because Watson's state depends on the state of the alarm, not on what triggered it. Conditioning again, we get
          $$P(A, W | B) = frac{P(A, W, B)}{P(B)} = frac{P(A, W, B)}{P(A, B)} frac{P(A, B)}{P(B)} = P(W | A, B) P(A | B) = P(W | A) P(A | B)$$
          and similarly
          $$P(A^prime, W | B) = P(W | A^prime) P(A^prime | B).$$
          Putting this together, we get
          $$P(B, W) = P(W | A) P(A | B) P(B) + P(W | A^prime) P(A^prime | B) P(B). \ = 0.9 cdot 0.99 cdot 0.01 + 0.5 cdot (1 - 0.99) cdot 0.01 \
          = 0.00891 + 0.00005 = 0.00896.$$



          To calculate $P(W)$ we would like to be able to use $A$ again and do the following direct calculation:
          $$P(W) = P(W, A) + P(W, A^prime) = P(W | A) P(A) + P(W | A^prime) P(A^prime)$$
          but unfortunately we don't know the marginal probabilities $P(A)$ or $P(A^prime)$, so we have to calculate them from the marginal probability that we do know, $P(B)$:
          $$P(A) = P(A, B) + P(A, B^prime) \= P(A | B) P(B) + P(A | B^prime) P(B^prime) \
          = 0.99 cdot 0.01 + 0.05 cdot (1 - 0.01) \ = 0.0099 + 0.0495 = 0.0594$$

          So $P(A) = 0.0594$ and $P(A^prime) = 1 - P(A) = 0.9406$.
          We can then calculate $P(W)$ as:
          $$P(W) = 0.9 cdot 0.0594 + 0.5 cdot 0.9406 = 0.52376.$$
          Finally,
          $$P(B | W) = frac{P(B, W)}{P(W)} = frac{0.00896}{0.52376} approx 0.0171.$$






          share|cite|improve this answer














          Firstly, I'm going to change notation, so that $W$ is ${W = tr}$ and $W^prime$ is the converse.



          We know that the events $B, W$ are conditionally independent given the alarm, so we want to think about the probability of both events for the possible states that the alarm can be in. We can calculate the numerator in your expression as $$P(B, W) = P(B, W, A) + P(B, W, A^prime).$$
          Now we want to convert this into probabilities that we know. The only marginal that we already know is $P(B)$ (and $P(B^prime)$), so we'll start by conditioning on $B$:
          $$P(B, W) = P(A, W | B) P(B) + P(A^prime, W | B) P(B).$$
          Due to the structure of the Bayes network we know that
          $$P(W | A, B) = P(W | A)$$
          because Watson's state depends on the state of the alarm, not on what triggered it. Conditioning again, we get
          $$P(A, W | B) = frac{P(A, W, B)}{P(B)} = frac{P(A, W, B)}{P(A, B)} frac{P(A, B)}{P(B)} = P(W | A, B) P(A | B) = P(W | A) P(A | B)$$
          and similarly
          $$P(A^prime, W | B) = P(W | A^prime) P(A^prime | B).$$
          Putting this together, we get
          $$P(B, W) = P(W | A) P(A | B) P(B) + P(W | A^prime) P(A^prime | B) P(B). \ = 0.9 cdot 0.99 cdot 0.01 + 0.5 cdot (1 - 0.99) cdot 0.01 \
          = 0.00891 + 0.00005 = 0.00896.$$



          To calculate $P(W)$ we would like to be able to use $A$ again and do the following direct calculation:
          $$P(W) = P(W, A) + P(W, A^prime) = P(W | A) P(A) + P(W | A^prime) P(A^prime)$$
          but unfortunately we don't know the marginal probabilities $P(A)$ or $P(A^prime)$, so we have to calculate them from the marginal probability that we do know, $P(B)$:
          $$P(A) = P(A, B) + P(A, B^prime) \= P(A | B) P(B) + P(A | B^prime) P(B^prime) \
          = 0.99 cdot 0.01 + 0.05 cdot (1 - 0.01) \ = 0.0099 + 0.0495 = 0.0594$$

          So $P(A) = 0.0594$ and $P(A^prime) = 1 - P(A) = 0.9406$.
          We can then calculate $P(W)$ as:
          $$P(W) = 0.9 cdot 0.0594 + 0.5 cdot 0.9406 = 0.52376.$$
          Finally,
          $$P(B | W) = frac{P(B, W)}{P(W)} = frac{0.00896}{0.52376} approx 0.0171.$$







          share|cite|improve this answer














          share|cite|improve this answer



          share|cite|improve this answer








          edited Nov 26 at 13:27

























          answered Nov 24 at 16:46









          Alex

          341212




          341212












          • thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
            – Amoz
            Nov 25 at 15:49












          • That was a mistake - thanks for spotting it. I've corrected my answer
            – Alex
            Nov 26 at 13:29


















          • thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
            – Amoz
            Nov 25 at 15:49












          • That was a mistake - thanks for spotting it. I've corrected my answer
            – Alex
            Nov 26 at 13:29
















          thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
          – Amoz
          Nov 25 at 15:49






          thank you so much. I have a question. You say we have $P(B, W) = P(B, W, A) + P(B, W, A') =$ $P(W, A | B) P(B) + P(W, A' | B) P(B) =\$ $P(A | B)P(W | A) P(B) + P(A' | B) P(W | A') P(B)\$ right? Then when you calculate it you say $P(B, W) = P(A | B) P(W | A) P(B) + P(W | A') P(A' | B') P(B')$ Where did the $B'$ come from in the last term?
          – Amoz
          Nov 25 at 15:49














          That was a mistake - thanks for spotting it. I've corrected my answer
          – Alex
          Nov 26 at 13:29




          That was a mistake - thanks for spotting it. I've corrected my answer
          – Alex
          Nov 26 at 13:29


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3011040%2fstruggling-with-bayes-network%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen