A long time ago I have written a code for a probability tree (see picture below), unfortunately i lost the code. Does somebody have an idea, how i can realize it again?
I have already tried an old version but it fails
\begin{figure}[H]
\centering
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.6cm,y=0.5cm]
\clip(0,-6.5) rectangle (18,6);
\draw [line width=2pt] (2,-1)-- (9,2);
\draw [line width=2pt] (2,-1)-- (9,-4);
\draw [line width=2pt] (9,2)-- (16,4);
\draw [line width=2pt] (9,2)-- (16,0);
\draw [line width=2pt] (9,-4)-- (16,-2);
\draw [line width=2pt] (9,-4)-- (16,-6);
\filldraw [red] (2,-1) circle (2.8pt);
\filldraw [red] (9,2) circle (2.8pt);
\filldraw [red] (9,-4) circle (2.8pt);
\filldraw [red] (16,-6) circle (2.8pt);
\filldraw [red] (16,-2) circle (2.8pt);
\filldraw [red] (16,4) circle (2.8pt);
\filldraw [red] (16,0) circle (2.8pt);
\node (A) at (9,2.8) {$V$};
\node (B) at (9,-3.2) {$\overline{V}$};
\node (C) at (16,4.8) {$S$};
\node (D) at (16,0.8) {$\overline{S}$};
\node (E) at (16,-1.2) {$S$};
\node (F) at (16,-5.2) {$\overline{S}$};
\node (G) at (5,1.5) {\scriptsize {\color{blue}$P(V)=0,4$}};
\node (G) at (5,-3.5) {\scriptsize {\color{blue}$P(\overline{V})=0,6$}};
\node (G) at (12,3.8) {\scriptsize {\color{blue}$P(S|V)=0,6$}};
\node (G) at (12,0) {\scriptsize {\color{blue}$P(\overline{S}|V)=0,4$}};
\node (G) at (12,-2) {\scriptsize {\color{blue}$P(S|\overline{V})=0,3$}};
\node (G) at (12,-6) {\scriptsize {\color{blue}$P(\overline{S}|\overline{V})=0,7$}};
\end{tikzpicture}
\caption{Baumdiagramm für Aufgabe 11}
\end{figure}
Best Answer
In short, to modify your code, replace all the instances where you have
with
Except for the first red circle, that you can just remove. And of course replace
$A$
with the appropriate symbol for the node in question. Here is a version of your code where I cleaned up a little bit. I didn't change the text in the nodes, but that you can manage.TikZ tree
However, this is a tree, so you could also use the tree drawing capabilities of TikZ, as such:
forest
Or using the more powerful
forest
package, which is rather popular I think. I'm no expert though, so it's quite possible the edge labels could be solved more elegantly.