# Simple Probability Tree

How do I make the following probability trees in LaTeX?

Thanks for the help!!

Probability Tree 1:

Probability Tree 2:

\forestset{my label/.style={if n=1{edge label={node [midway, above left, font=\tiny] {$#1$}},}{edge label={node [midway, below left, font=\tiny] {$#1$}},
}
}
}

\begin{forest}
for tree={
grow'=0,
math content,
parent anchor=east,
child anchor=west,
edge path={
\noexpand\path [\forestoption{edge}] (!u.parent anchor) node
[circle, fill, minimum size=2.5pt, inner sep=0pt,
anchor=center]
{} -- (.child anchor)\forestoption{edge label};
},
edge={->},
anchor=west,
l sep+=15mm,
s sep+=10mm,
}

%Left figure
[
[\textbf{\textit{p}}^{good}, my label={P(good\rvert club_1)},
tikz={\node (sa) [above=10mm of .north, anchor=base] {$S_A$};}]
]

[, phantom, l sep-=25mm

%Right figure

[
[\textbf{\textit{p}}^{good}, my label={P(good\rvert club_2)},
tikz={\node (sb) [anchor=base east] at (.west |- sa.base) {$S_B$};
\draw [thick] (!r |- sa.south) -- (.east |- sa.south);}]

]
]
\end{forest}


Probability Tree 3:

• Hello. Start with a minimal working example please. Jul 29 '15 at 22:41
• Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
– user31729
Jul 29 '15 at 22:45

Here is the most complex tree. You should be able to modify it to produce the simpler trees. If you get stuck, just post the code you have and ask how to solve the problem you come across.

This uses the powerful forest package which allows the standard bracket notation to be used for drawing trees. My answer to an earlier question introduces forest and explains how to turn a tree into a bracket specification.

\documentclass[tikz, border=10pt]{standalone}
\usepackage{forest,mathtools}
\usetikzlibrary{arrows.meta,positioning}% requires TikZ/PGF 3 - comment if you don't have arrows.meta
%\usetikzlibrary{positioning}% uncomment if you don't have arrows.meta
\begin{document}
\forestset{
my label/.style={
if n=1{
edge label={node [midway, above left, font=\tiny] {$#1$}},
}{
edge label={node [midway, below left, font=\tiny] {$#1$}},
}
}
}
\begin{forest}
for tree={
grow'=0,
math content,
parent anchor=east,
child anchor=west,
edge path={
\noexpand\path [\forestoption{edge}] (!u.parent anchor) node [circle, fill, minimum size=2.5pt, inner sep=0pt, anchor=center] {} -- (.child anchor)\forestoption{edge label};
},
edge={-{Stealth[]}},% requires TikZ/PGF version 3 - comment if you don't have arrows.meta
%edge={->},% uncomment this line if you don't have arrows.meta
anchor=west,
l sep+=15mm,
s sep+=5mm,
}
[
[p^{good}, my label={P[good\rvert club_1]}, tikz={\node (sa) [above=10mm of .north, anchor=base] {$S_A$};}
]
[, phantom, l sep-=25mm
[
[p^{good}, my label={P[good\rvert club_2]},
tikz={
\node (sb) [anchor=base east] at (.west |- sa.base) {$S_B$};
\draw [thick] (!r |- sa.south) -- (.east |- sa.south);
}
]
]
]
]
]
]
]
]
\end{forest}
\end{document}


# EDIT

Here is some help with all three trees:

\documentclass[tikz, border=10pt, multi]{standalone}
\usepackage{forest,mathtools}
\usetikzlibrary{arrows.meta,positioning}
\begin{document}
\forestset{
my label/.style={
if n=1{
edge label={node [midway, above left, font=\tiny] {$#1$}},
}{
edge label={node [midway, below left, font=\tiny] {$#1$}},
}
}
}

\begin{forest}
for tree={
grow'=0,
math content,
parent anchor=east,
child anchor=west,
edge path={
\noexpand\path [\forestoption{edge}] (!u.parent anchor) node [circle, fill, minimum size=2.5pt, inner sep=0pt, anchor=center] {} -- (.child anchor)\forestoption{edge label};
},
edge={-{Stealth[]}},
anchor=west,
l sep+=15mm,
s sep+=5mm,
if level=1{tier=t}{}
}
[
[p^{bad}_{O.B.}, tikz={\node (sa) [above=10mm of .north, anchor=base east] {$unplayable$};}
]
[, phantom
[,
tikz={
\node (sb) [anchor=base east] at (.center |- sa.base) {$playable$};
\draw [thick] (!r |- sa.south) -- (.east |- sa.south);
}
]
]
]
]
]
]
\end{forest}
\begin{forest}
for tree={
grow'=0,
math content,
parent anchor=east,
child anchor=west,
edge path={
\noexpand\path [\forestoption{edge}] (!u.parent anchor) node [circle, fill, minimum size=2.5pt, inner sep=0pt, anchor=center] {} -- (.child anchor)\forestoption{edge label};
},
edge={-{Stealth[]}},
anchor=west,
l sep+=15mm,
s sep+=5mm,
if level=1{tier=t}{}
}
[
[p^{good}, my label={P[good\rvert club_1]}, tikz={\node (sa) [above=10mm of .north, anchor=base] {$S_A$};}
]
[, phantom
[,
[p^{good}, my label={P[good\rvert club_2]},
tikz={
\node (sb) [anchor=base east] at (.west |- sa.base) {$S_B$};
\draw [thick] (!r |- sa.south) -- (.east |- sa.south);
}
]
[,phantom]
]
]
]
]
]
\end{forest}
\begin{forest}
for tree={
grow'=0,
math content,
parent anchor=east,
child anchor=west,
edge path={
\noexpand\path [\forestoption{edge}] (!u.parent anchor) node [circle, fill, minimum size=2.5pt, inner sep=0pt, anchor=center] {} -- (.child anchor)\forestoption{edge label};
},
edge={-{Stealth[]}},
anchor=west,
l sep+=15mm,
s sep+=5mm,
}
[
[p^{good}, my label={P[good\rvert club_1]}, tikz={\node (sa) [above=10mm of .north, anchor=base] {$S_A$};}
]
[, phantom, l sep-=25mm
[
[p^{good}, my label={P[good\rvert club_2]},
tikz={
\node (sb) [anchor=base east] at (.west |- sa.base) {$S_B$};
\draw [thick] (!r |- sa.south) -- (.east |- sa.south);
}
]
]
]
]
]
]
]
]
\end{forest}
\end{document}


Take a look at the answer I linked above for help understanding the bracket notation. Else this will just seem like magic tricks and be impossible for you to adapt ;).

• This is great!!! Thank you what if it were in a \documentclass{article} ? Jul 29 '15 at 23:27
• @Andrew It will work fine in article. standalone is just good for making examples or working on images before including them in a main document. Just add the \usepackage... and \usetikzlibrary... to your document and then include the code for the tree. You can e.g. put it in a \begin{figure}...\end{figure} or however you wish ;).
– cfr
Jul 29 '15 at 23:59
• for some reason, my up-to-date version of MiKTeX does not like \usetikzlibrary{arrows.meta} . This is what the error message says: ! I can't find file tikzlibraryarrows.meta.code.tex. <argument> ...nput tikzlibrary\pgf@temp .code.tex Jul 30 '15 at 0:23
• @Andrew That is an update problem. MikTeX definitely now has TikZ/PGF version 3 available. However, you can drop that library and change -{Stealth[]} to -> in the definition of edge if you don't want to update.
– cfr
Jul 30 '15 at 0:48
• @Andrew I've added some commented lines to make this clearer. If you'd rather not update, just comment the \usetikzlibrary and edge lines indicated and uncomment the alternatives just below them.
– cfr
Jul 30 '15 at 1:22