Un arbre de probabilité 3×2

arbre32-2.jpg

Voici son code :

input geometriesyr16.mp ;

%------------------------------------------------------------------------
% Arbre 3x2
%------------------------------------------------------------------------

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

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

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

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

S:= 0.5[T[1],T[3]] 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[2],U[3]]--(1-cr)[T[2],U[3]];
draw cr[T[2],U[4]]--(1-cr)[T[2],U[4]];
draw cr[T[3],U[5]]--(1-cr)[T[3],U[5]];
draw cr[T[3],U[6]]--(1-cr)[T[3],U[6]];

%----------- premier niveau
label(btex $A$ etex,T[1]);
label.ulft(btex $1 \over 6$ etex,0.6[S,T[1]]);

label(btex $B$ etex,T[2]);
label.ulft(btex $1 \over 3$ etex,0.6[S,T[2]]);

label(btex $C$ etex,T[3]);
label.llft(btex $1 \over 2$ etex,0.6[S,T[3]]);

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

label(btex $\overline{E}$ etex,U[2]);
label.llft(btex $0,9$ etex,0.6[T[1],U[2]]);

%----------- deuxième niveau central
label(btex $E$ etex,U[3]);
label.ulft(btex $0,3$ etex,0.6[T[2],U[3]]);

label(btex $\overline{E}$ etex,U[4]);
label.llft(btex $0,7$ etex,0.6[T[2],U[4]]);

%----------- deuxième niveau inférieur
label(btex $E$ etex,U[5]);
label.ulft(btex $0,4$ etex,0.6[T[3],U[5]]);

label(btex $\overline{E}$ etex,U[6]);
label.llft(btex $0,6$ etex,0.6[T[3],U[6]]);

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


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