Un arbre de probabilité 3×3

arbre33.png

Voici son code :

input geometriesyr16.mp ;

%------------------------------------------------------------------------
% Arbre 2x3
%------------------------------------------------------------------------

u:=1cm;
figure (-8u,-20u,10u,8u);
pair S,T[],U[];

numeric dx,dh,cr;
dx:=3;
dh:=1.5;
cr:=0.1;

for i:=1 upto 9:
  U[i]:=(2*dx*u,-i*dh*u);
endfor

T[1]:= U[2] shifted(-dx*u,0);
T[2]:= U[5] shifted(-dx*u,0);
T[3]:= U[8] shifted(-dx*u,0);

S:= T[2] shifted(-dx*u,0);

draw cr[S,T[1]]--(1-cr)[S,T[1]];
draw cr[S,T[2]]--(1-cr)[S,T[2]];
draw cr[S,T[3]]--(1-cr)[S,T[3]];
draw cr[T[1],U[1]]--(1-cr)[T[1],U[1]];
draw cr[T[1],U[2]]--(1-cr)[T[1],U[2]];
draw cr[T[1],U[3]]--(1-cr)[T[1],U[3]];
draw cr[T[2],U[4]]--(1-cr)[T[2],U[4]];
draw cr[T[2],U[5]]--(1-cr)[T[2],U[5]];
draw cr[T[2],U[6]]--(1-cr)[T[2],U[6]];
draw cr[T[3],U[7]]--(1-cr)[T[3],U[7]];
draw cr[T[3],U[8]]--(1-cr)[T[3],U[8]];
draw cr[T[3],U[9]]--(1-cr)[T[3],U[9]];


%----------- premier niveau
label(btex $A_0$ etex,T[1]);
label.ulft(btex $6/15$ etex,0.6[S,T[1]]);

label(btex $A_1$ etex,T[2]);
label.llft(btex $8/15$ etex,0.6[S,T[2]]);

label(btex $A_2$ etex,T[3]);
label.llft(btex $1/15$ etex,0.6[S,T[3]]);

%----------- deuxième niveau supérieur
label(btex $B_0$ etex,U[1]);
label.ulft(btex $1/6$ etex,0.6[T[1],U[1]]);

label(btex $B_1$ etex,U[2]);
label.ulft(btex $4/6$ etex,0.6[T[1],U[2]]);

label(btex $B_2$ etex,U[3]);
label.llft(btex $1/6$ etex,0.6[T[1],U[3]]);

%----------- deuxième niveau centrale
label(btex $B_0$ etex,U[4]);
label.ulft(btex $3/6$ etex,0.6[T[2],U[4]]);

label(btex $B_1$ etex,U[5]);
label.ulft(btex $3/6$ etex,0.6[T[2],U[5]]);

label(btex $B_2$ etex,U[6]);
label.llft(btex $0$ etex,0.6[T[2],U[6]]);

%----------- deuxième niveau inférieur
label(btex $B_0$ etex,U[7]);
label.ulft(btex $1$ etex,0.6[T[3],U[7]]);

label(btex $B_1$ etex,U[8]);
label.ulft(btex $0$ etex,0.6[T[3],U[8]]);

label(btex $B_2$ etex,U[9]);
label.llft(btex $0$ etex,0.6[T[3],U[9]]);

fin;
 %-----------------------------------------------------------------------


%-----------------------------------------------------------------------
end ;