Sarmate.net Sarmate.net
Home Features Pricing Documentation Contact
Log in Sign up

LaTeX Probability Tree — No Install, No Coding

Our visual editor builds the tree branch by branch and generates the TikZ code. Ready presets (coin flip, urn, conditional, binomial), mouse-driven editing, math-mode labels. Compile PDF directly.

No install No signup 100% free

A LaTeX probability tree is advanced TikZ

Any math teacher who has tried to drop a tree into an exam knows it: you need TikZ, you compute node coordinates, and you align them cleanly. Three frictions show up every time — those are what we fix.

Node coordinates

Each node (root, branches, leaves) must be positioned. The wider the tree, the more you must spread the leaves to avoid label overlap.

Branch labels

Probabilities below, on top, or in the middle of each edge? Math mode for fractions? node[midway, above] on every edge gets repetitive.

Re-doing the tree on every change

Add a branch? All downstream coordinates shift. Change depth? Recompute the whole spacing.

The Sarmate.net solution

Our tree editor starts from a preset (coin flip, urn, conditional, binomial) and lets you add, remove, or edit branches with the mouse. The TikZ code is generated and updated in real time.

Ready presets

Coin flip, urn (2 draws), conditional probability, binomial (n=3) — pick a preset and customize. You're 90% of the way there.

Visual editing

Click to add or remove branches. Drag to reorder. Math-mode labels (KaTeX) with instant preview. Label position (above, on, below) in one click.

Clean TikZ code

Generated code uses standard TikZ conventions (\node, \draw, automatic spacing). Copy it or compile directly in the browser.

How it works in 3 steps

1

1. Pick a preset

Coin flip, urn, conditional, binomial — or free structure 2×2, 3×2, 2×3.

2

2. Customize branches

Rename nodes (A, B, R, G…), change probabilities (1/2, 0.3, p, 1-p…), adjust label positions.

3

3. Grab the code (or the PDF)

Copy the tikzpicture block, compile the PDF directly in the browser, or save to your Sarmate drive.

A few generated trees

Coin flip (2 tosses)
\begin{tikzpicture}[level distance=20mm, sibling distance=22mm]
\node {} child { node {P} edge from parent node[above left] {$\frac{1}{2}$} } child { node {F} edge from parent node[above right] {$\frac{1}{2}$} };
\end{tikzpicture}
Urn with 2 draws
\begin{tikzpicture}[grow=right, level distance=22mm, sibling distance=14mm, edge from parent/.style={draw,->}]
\node {} child { node {R} child { node {R} edge from parent node[above] {$\frac{2}{4}$} } child { node {V} edge from parent node[below] {$\frac{2}{4}$} } edge from parent node[above] {$\frac{3}{5}$} } child { node {V} child { node {R} edge from parent node[above] {$\frac{3}{4}$} } child { node {V} edge from parent node[below] {$\frac{1}{4}$} } edge from parent node[below] {$\frac{2}{5}$} };
\end{tikzpicture}
Conditional probability
\begin{tikzpicture}[level distance=22mm, sibling distance=22mm]
\node {} child { node {A} child { node {B} edge from parent node[above left] {$P_A(B)$} } edge from parent node[above left] {$P(A)$} } child { node {\overline{A}} child { node {B} edge from parent node[above right] {$P_{\overline{A}}(B)$} } edge from parent node[above right] {$P(\overline{A})$} };
\end{tikzpicture}
Bernoulli scheme (n=3)
\begin{tikzpicture}[level distance=18mm, sibling distance=24mm]
\node {} child { node {S} child { node {S} child { node {S} } child { node {E} } } child { node {E} child { node {S} } child { node {E} } } } child { node {E} child { node {S} child { node {S} } child { node {E} } } child { node {E} child { node {S} } child { node {E} } } };
\end{tikzpicture}

Hand-coded TikZ vs Sarmate.net

By handWith Sarmate.net
Time for a 2×2 tree15 to 30 minUnder a minute
Coordinate computationManual, tediousAutomatic
Modify one branchRecompute everything downstreamAuto re-adjust
Labels (\(\frac{1}{2}\), p, q…)node[midway, above] per edgeInput field
Visual previewRecompile every timeReal-time
Ready-to-use presetsSearch the internet4 built-in presets

Frequently asked questions

How do I make a probability tree in LaTeX?+
The standard is to use TikZ with \node for each node and \draw for edges — often loading \usetikzlibrary{positioning} for below=of, right=of, etc. Precise but verbose. Our editor does all that with the mouse and gives you ready-to-paste code.
Which package for LaTeX probability trees?+
Several options: TikZ alone (most flexible), tikz-qtree (simplified tree syntax), forest (very powerful for complex trees), or dedicated packages like prob-trees. Our editor generates standard TikZ — no extra package to install.
How do I write fractions on branches (probabilities)?+
In TikZ, an edge label is a node. Math content goes between $…$ — e.g. node[midway, above] {$\frac{1}{2}$}. Our editor accepts 1/2 directly and converts it to \frac{1}{2}, or you can write the LaTeX formula directly.
How do I position labels (above / below / on the branch)?+
TikZ options are [midway, above], [midway, below], or [pos=0.5, sloped] (on the line). For a downward-right branch, above can visually clash — sometimes below is preferable. Our editor exposes the three choices through a menu, with instant preview.
My tree overflows the page — how do I fit it?+
Three techniques: shrink with \begin{tikzpicture}[scale=0.8], reduce spacing with node distance=1cm, or orient the tree horizontally (left-to-right rather than top-to-bottom). For a very wide tree, \resizebox{\textwidth}{!}{...} around the tikzpicture caps the width at text width.

Ready to stop tweaking node[midway] directives?

Open the tree editor in one click. No signup for the demo.

Launch the tree editor now