# Probability tree

> Two stages of events with branch probabilities and the probability of each outcome. A Trees example with its LaTeX source.

A Trees example in the TeXeR TikZ library: https://texer.org/library/trees/probability-tree

Package: [Trees](https://texer.org/library/trees.md), on CTAN at https://ctan.org/pkg/pgf.

Tags: probability tree, conditional probability, statistics

## Source

```latex
\begin{tikzpicture}[
  grow=right, sloped,
  level 1/.style={level distance=30mm, sibling distance=28mm},
  level 2/.style={level distance=30mm, sibling distance=13mm},
  every node/.style={font=\small},
  edge from parent/.style={draw, thick},
  event/.style={draw, rounded corners, inner sep=3pt},
  outcome/.style={anchor=west},
]
  \node[circle, fill, inner sep=1.5pt] {}
  child { node[event] {Dry}
    child { node[outcome] {On time \quad $0.7 \times 0.9 = 0.63$} edge from parent node[below] {$0.9$} }
    child { node[outcome] {Late \quad $0.7 \times 0.1 = 0.07$} edge from parent node[above] {$0.1$} }
    edge from parent node[below] {$0.7$}
  }
  child { node[event] {Rain}
    child { node[outcome] {On time \quad $0.3 \times 0.4 = 0.12$} edge from parent node[below] {$0.4$} }
    child { node[outcome] {Late \quad $0.3 \times 0.6 = 0.18$} edge from parent node[above] {$0.6$} }
    edge from parent node[above] {$0.3$}
  };
\end{tikzpicture}
```

## As a complete document

The same example in a document that compiles on its own with pdfLaTeX:

```latex
\documentclass[margin=3mm]{standalone}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}
\begin{tikzpicture}[
  grow=right, sloped,
  level 1/.style={level distance=30mm, sibling distance=28mm},
  level 2/.style={level distance=30mm, sibling distance=13mm},
  every node/.style={font=\small},
  edge from parent/.style={draw, thick},
  event/.style={draw, rounded corners, inner sep=3pt},
  outcome/.style={anchor=west},
]
  \node[circle, fill, inner sep=1.5pt] {}
  child { node[event] {Dry}
    child { node[outcome] {On time \quad $0.7 \times 0.9 = 0.63$} edge from parent node[below] {$0.9$} }
    child { node[outcome] {Late \quad $0.7 \times 0.1 = 0.07$} edge from parent node[above] {$0.1$} }
    edge from parent node[below] {$0.7$}
  }
  child { node[event] {Rain}
    child { node[outcome] {On time \quad $0.3 \times 0.4 = 0.12$} edge from parent node[below] {$0.4$} }
    child { node[outcome] {Late \quad $0.3 \times 0.6 = 0.18$} edge from parent node[above] {$0.6$} }
    edge from parent node[above] {$0.3$}
  };
\end{tikzpicture}
\end{document}
```
