locked
Understanding the noisy assignment in Causality example RRS feed

  • Question

  • I am currently going through the "Causal Inference with Infer.NET" article by John Winn.

    https://blogs.msdn.microsoft.com/infernet_team_blog/2012/01/27/causal-inference-with-infer-net/

    While I understand the reasoning behind how the model is constructed and why it works, I just can't get around the workings of this line of code:

    B[N] = A[N] != Variable.Bernoulli(q);

    The double value of q governs how noisy copy of A the B will be. The smaller value q, the more B is similar to A. If the value is large, say 0.4, the more noisy it will be.

    My question is: I don't understand by looking at this line of code how varying the value of q makes this happen? In my understanding, the condition is checked and the outcome is assigned to B. To me, changing q from small value to larger value, does not translate in that behavior. I am missing something? Are there some examples that might help to understand this better?

    The A and B are arrays of Variable<bool> type Variable.Bernoulli(). The both arrays are of the same length.

    Thanks


    • Edited by usptact Thursday, May 4, 2017 6:45 PM
    Thursday, May 4, 2017 6:43 PM

Answers

  • Your version is mathematically equivalent but less compact and less efficient.
    • Marked as answer by usptact Wednesday, August 16, 2017 9:03 PM
    Friday, May 5, 2017 4:26 PM
    Owner

All replies

  • After playing a bit, I think I've come up with equivalent code which seems to be easier to understand (to me) at expense of more code lines.

    var x = Variable.Bernoulli(q);
    using (Variable.If(x))
    {
       B[N] = !A[N];
    }
    using (Variable.IfNot(x))
    {
       B[N] = A[N];
    }
    Is this exactly equivalent to that original line of code? 

    Friday, May 5, 2017 6:58 AM
  • Your version is mathematically equivalent but less compact and less efficient.
    • Marked as answer by usptact Wednesday, August 16, 2017 9:03 PM
    Friday, May 5, 2017 4:26 PM
    Owner