How to create a probability tree and calc prob of each branch?

4 visualizaciones (últimos 30 días)
I have six events and each event has a known probability of occurring first. All six occur but the order is unknown. There is thus one starting point and 6! (thus 720) ending points. I need to know the sequence of events and probability associated with each end point. This is probability tree 101. How do I set up such a tree in MATLAB (I do have Stat Toolbox)?
Thank you.

Respuesta aceptada

jeff bodington
jeff bodington el 2 de Jul. de 2014
Perfect! Thank you. I did not know about "perms" and how to use reshape.
  1 comentario
Image Analyst
Image Analyst el 5 de Jul. de 2014
You can "thank" him by "Accepting his answer to give him reputation points which give him additional powers to do things in this forum.

Iniciar sesión para comentar.

Más respuestas (1)

Roger Stafford
Roger Stafford el 2 de Jul. de 2014
I assume that after the first event the following events occur with the same probabilities as the first events but conditioned on previous events not occurring. If so, do the following.
Let p be a vector of the probabilities of each of the events occurring first. These must sum to 1.
n = length(p);
r = perms(1:n); % Get list of all possible permutations
q = prod(p)./prod(cumsum(reshape(p(fliplr(r)),[],n),2),2);
Then q will be a list of the probabilities of each of the corresponding permutations in r - that is, the probability of each "end point". The values in q will sum to 1 (except for round-off error.)
  2 comentarios
jeff bodington
jeff bodington el 8 de Jul. de 2014
Woops, the code for "q = ..." does not execute. I have trid to debug it but have failed so far. Can you please take another look. Thank you.
Roger Stafford
Roger Stafford el 8 de Jul. de 2014
I suggest you break up the code for 'q' into the following steps and see at which step your trouble occurs. (I don't seem to have any trouble with it.)
t1 = fliplr(r);
t2 = p(t1);
t3 = reshape(t2,[],n);
t4 = cumsum(t3,2);
t5 = prod(t4,2);
t6 = prod(p);
t7 = t6./t5;
If n = 6, t1 should be a 720 x 6 array, t2 a 4320 x 1 vector, t3 a 720 x 6 array, t4 also 720 x 6, t5 a 720 x 1 vector, t6 a scalar (1 x 1), and t7 a 720 x 1 vector.

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by