1
$\begingroup$

I'm not sure if there is a gap in my stats knowledge or Mathematica knowledge but it's time to ask for help.

I have the following system I am trying to calculate the condition probability of getting to stage 3.

Finding the joint distribution is straightforward:

Block[{A, B, C, p},
 {A, B, C} = {0.2528674027226927, 0.506570580754557, 0.705439330543933};

 p = NProbability[
   c == 1 && b == 1 && 
    a == 1 , {a \[Distributed] BernoulliDistribution[A], 
    b \[Distributed] BernoulliDistribution[B], 
    c \[Distributed] BernoulliDistribution[C]}];

 p
]
(* results 0.0903634 *)    

However, to me this network needs to be modelled conditionally since how many draws make it to stage 3 depends on passing stage 1 and 2. However, I've tried a couple of different ways and my answers don't seem reasonable when compared to the initial values. I was expecting a value under ~0.25. Does anyone notice anything wrong with me code?

Block[{results, prob, A, B, C},
 {A, B, C} = {0.2528674027226927, 0.506570580754557, 0.705439330543933};

 prob = Probability[
   b == 1 \[Conditioned] 
    a == 1, {a \[Distributed] BernoulliDistribution[A], 
    b \[Distributed] BernoulliDistribution[B]}];

 results = 
  Probability[c == 0 \[Conditioned] prob, 
   c \[Distributed] BernoulliDistribution[C]];
 
 results
 ]
 (* returns \[Piecewise]    
             0.294561   0.506571
             0  True.   *)
$\endgroup$
4
  • 1
    $\begingroup$ I don't really know what your system represents, but purely from the mathematical viewpoint, the probability $0.0904$ seems correct to me. There is only one way to the stage 3: start -> stage 1 -> stage 2 -> stage 3. So the probability for all three steps to occur is the product of probabilities for each step(since they are – I suppose – independent). Therefore: $p = 0.253 \times 0.507 \times 0.705 = 0.0904$. $\endgroup$
    – Domen
    Commented Jul 13, 2021 at 18:38
  • $\begingroup$ Just wondering... Do you want to model a card game like poker or black jack? Whatever you want to model, I suggest editing your question and adding a description of it. Anchoring something in a specific domain will often get you more and better answers. $\endgroup$
    – Jagra
    Commented Jul 13, 2021 at 18:43
  • $\begingroup$ Is what you want the probability of getting to Stage 3? If you want a "conditional" probability, you need to state what you're conditioning on. $\endgroup$
    – JimB
    Commented Jul 13, 2021 at 20:03
  • $\begingroup$ Never use upper-case letters to start names for variables as they can conflict with Mathematica's internal naming. $\endgroup$ Commented Jul 13, 2021 at 21:41

1 Answer 1

3
$\begingroup$

Couldn't you model this as a DiscreteMarkovProcess?

(* states are start(1), stage1(2), stage2(3), stage3(4), missing(5) *)
proc = DiscreteMarkovProcess[{1, 0, 0, 0, 0},
   {{0, 0.253, 0, 0, 0.747},
    {0, 0, 0.507, 0, 0.493},
    {0, 0, 0, 0.705, 0.295},
    {0, 0, 0, 1, 0},
    {0, 0, 0, 0, 1}
    }];

Graph[proc]

PDF[StationaryDistribution[proc], 4]
(* 0.0904311 which also happens to be 0.253 * 0.507 * 0.705 *)

Stage 3 (vertex 4) and Missing (vertex 5) are both absorbing states in the graph. You could also calculate Probability[x[3] == 4, x \[Distributed] proc] and get the same answer. markov chain graph

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.