Prev: SVM
Next: Hide Z axis in mesh plot
From: hopla on 11 Mar 2010 03:00 Hello, I just want to know if there is a matlabfunction or mfile that gives me the probabilities of a tree. For example if i have a probability tree with each step a chance of 0.95 and 0.05 and i have 4 steps. How can show get the 16 possible results with there probability? It seems a very easy problem to me, so i guess there is a way to fix it but i can not find it. Thanks in advance!
From: Walter Roberson on 11 Mar 2010 13:22 hopla wrote: > I just want to know if there is a matlabfunction or mfile that gives me the probabilities of a tree. > For example if i have a probability tree with each step a chance of 0.95 and 0.05 and i have 4 steps. How can show get the 16 possible results with there probability? > It seems a very easy problem to me, so i guess there is a way to fix it but i can not find it. P = [0.95 0.05]; LR = 'LR'; S=4; prob = zeros(2^S,1); tree = repmat(' ',2^S,S); for K = 0:2^S-1 b = dec2bin(K,S); prob(K+1) = prod(P(1 + b=='1')); tree(K+1,:) = LR(1 + b=='1'); end for K = 1:length(prob) disp( 'Tree ', tree(K,:), ' had probability ', prob(K)); end
|
Pages: 1 Prev: SVM Next: Hide Z axis in mesh plot |