# Binomial tree using TikZ

I'm trying to reproduce the following binomial tree using TikZ:

I can't find the right proportions for the tree itself, it seems a little bit asymmetric.

My minimal code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}

\draw[thick] (0,0) circle (.5cm);

% –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– %

\coordinate (a1) at (.45,.2);

\coordinate (a2) at (4,1.0875);
\draw[thick] (4.5,1.2125) circle (.5cm);
\coordinate (a3) at (5,1.3375);

\coordinate (a4) at (8,2.0875);
\draw[thick] (8.5,2.2125) circle (.5cm);
\coordinate (a5) at (9,2.3375);

\coordinate (a6) at (12.45,3.2);
\draw[thick] (12.95,3.325) circle (.5cm);

\draw[thick] (a1) -- (a2);
\draw[thick] (a3) -- (a4);
\draw[thick] (a5) -- (a6);

% –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––%

\coordinate (a7) at (.45,-.2);

\coordinate (a8) at (4,-1.0875);
\draw[thick] (4.5,-1.2125) circle (.5cm);
\coordinate (a9) at (5,-1.3375);

\coordinate (a10) at (8,-2.0875);
\draw[thick] (8.5,-2.2125) circle (.5cm);
\coordinate (a11) at (9,-2.3375);

\coordinate (a12) at (12.45,-3.2);
\draw[thick] (12.95,-3.325) circle (.5cm);

\draw[thick] (a7) -- (a8);
\draw[thick] (a9) -- (a10);
\draw[thick] (a11) -- (a12);

% –––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– %

\coordinate (a13) at (4.935,.-0.95);
\draw[thick] (8.5,0) circle (.5cm);
\coordinate (a14) at (8.05,-0.2);

\coordinate (a15) at (8.95, .2);
\coordinate (a16) at (12.45, .7387);

\draw[thick] (12.95,0.85) circle (.5cm);

\draw[thick] (a13) -- (a14);
\draw[thick] (a15) -- (a16);

\coordinate (a17) at (4.95,1);
\coordinate (a18) at (8.05,.2);

\draw[thick] (a17) -- (a18);

\draw[thick] (12.95,-1.2125) circle (.5cm);
\draw[thick] (8.95,-.2) -- (12.475, -1.05);

\end{tikzpicture}

\end{document}

• Put at (x, y) the coefficient \binom{x+y}{x}. Use \pgfmathsetmacro to do arithmetic. – Symbol 1 Oct 5 '20 at 19:11
• You can try with forest. – projetmbc Oct 5 '20 at 22:28

And relative short code with forest:


\documentclass[margin=3mm]{standalone}
\usepackage{forest}
\newcommand\nd[1]{\texttt{#1}}

\begin{document}
\begingroup
\tikzset{every label/.style = {font=\footnotesize,inner sep=0pt, anchor=south west}}
\begin{forest}
for tree = {
circle, draw, minimum size=2em, inner sep=0pt,
math content,
grow'=0,
calign = fixed edge angles, calign angle=40,
}
[1
[2,name=n11, calign=last%i
[2,
[8, label={$H_{3,3}=0$}]
[,phantom]
[2, label={$H_{3,2}=\frac{1}{2}$}, name=n31]
]
[,phantom]
]
[,phantom
[1,name=n21
]
]
[\frac{1}{2},name=n12,calign=first%p
[,phantom]
[\frac{1}{2}, name=n22 %h
[\frac{1}{2}, label={$H_{3,1}=2$},name=n32]
[,phantom]
[\frac{1}{8}, label={$H_{3,0}=\frac{19}{8}$}]
]
]
]
\draw   (n11) -- (n21) (n12) -- (n21)
(n21) -- (n31) (n21) -- (n32);
\end{forest}
\endgroup
\end{document}


You can have this tree with a short code in pstricks:

\documentclass[pstricks]{standalone}
\usepackage{pst-node}

\begin{document}

\psset{unit=1cm}
\begin{pspicture}(1,-0.6)(1,5.6)
$\begin{psmatrix}[mnode=R, rowsep=1.2em, colsep=2cm] & & & & [name=C] 8\\ & & & [name=B] 4\\ & & [name=A] 2 & & [name=D] 2 \\% & [name=I] 1 & & [name=J] 1 \\ & &[name=a] \frac{1}{2} & & [name=d] \frac{1}{2} \\ & & & [name=b] \frac{1}{4}\\ & & & & [name=c] \frac{1}{8} \end{psmatrix} \foreach \c in {I, A, B, C, a, b, c, J, D, d}{\pscircle(\c) {1.2em}} \foreach \s\t in \foreach \s\t in {I/A, A/B, B/C, I/a, a/b, b/c, A/J, a/J, B/D, J/D, b/d, J/d}{\ncline[nodesep=0.84em]{\s}{\t}}\ncline[nodesep=0.9em]{\s}{\t}} \uput{1.4em}[u](C){H_{3,3}=0} \uput{1.3em}[u](D){H_{3, 2}=\frac{1}{2}} \uput{1.4em}[u](d){H_{3, 1}=2} \uput{1.2em}[u](c){H_{3, 0}=\frac{19}{8}}$
\end{pspicture}

\end{document}


• Really like this but you missed a path from the second step to the third one. Thanks a lot! – polaris7 Oct 6 '20 at 8:17
• @polaris7: Fixed, mylord! – Bernard Oct 6 '20 at 10:57