BEARBEITEN

BEARBEITEN

Wie erstelle ich die folgenden Wahrscheinlichkeitsbäume in LaTeX?

Danke für die Hilfe!!


Wahrscheinlichkeitsbaum 1:

Wahrscheinlichkeitsbaum 1

Wahrscheinlichkeitsbaum 2:

Wahrscheinlichkeitsbaum 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$};}]
   [\textbf{\textit{p}}_{rough}^{bad}, my label={P(bad\rvert club_1)}]
]


[, 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);}]

[\textbf{\textit{p}}^{bad}_{rough}, my label={P(bad\rvert club_2)}]
]
]
\end{forest}

Wahrscheinlichkeitsbaum 3:

Wahrscheinlichkeitsbaum 3

Antwort1

Hier ist der komplexeste Baum. Sie sollten ihn ändern können, um einfachere Bäume zu erstellen. Wenn Sie nicht weiterkommen, posten Sie einfach den Code, den Sie haben, und fragen Sie, wie Sie das aufgetretene Problem lösen können.

Dabei wird das leistungsstarke forestPaket verwendet, das die Verwendung der Standardklammernotation zum Zeichnen von Bäumen ermöglicht.Meine Antwort auf eine frühere Fragestellt vor forestund erklärt, wie man einen Baum in eine Klammerspezifikation umwandelt.

\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$};}
    ]
    [p^{bad}, my label={P[bad\rvert club_1]}
      [p^{bad}_{rough}, my label={\delta\cdot P[bad\rvert club_1]}
        [, 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);
              }
            ]
            [p^{bad}_{rough}, my label={P[bad\rvert club_2]}
            ]
          ]
        ]
      ]
      [p^{bad}_{sand}, my label={(1-\delta)\cdot P[bad\rvert club_1]}
      ]
    ]
  ]
\end{forest}
\end{document}

Wahrscheinlichkeitsbaum

BEARBEITEN

Hier finden Sie Hilfe zu allen drei Bäumen:

\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
      [,
        [p^{bad}_{rough},
          tikz={
            \node (sb) [anchor=base east] at (.center |- sa.base) {$playable$};
            \draw [thick] (!r |- sa.south) -- (.east |- sa.south);
          }
        ]
        [p^{bad}_{trees}]
        [p^{bad}_{sand}
        ]
      ]
    ]
    [p^{bad}_{water}
    ]
  ]
\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]
        [p^{bad}_{rough}, my label={P[bad\rvert club_2]}
        ]
      ]
    ]
    [p^{bad}_{rough}, my label={P[bad\rvert club_1]}
    ]
  ]
\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$};}
    ]
    [p^{bad}, my label={P[bad\rvert club_1]}
      [p^{bad}_{rough}, my label={\delta\cdot P[bad\rvert club_1]}
        [, 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);
              }
            ]
            [p^{bad}_{rough}, my label={P[bad\rvert club_2]}
            ]
          ]
        ]
      ]
      [p^{bad}_{sand}, my label={(1-\delta)\cdot P[bad\rvert club_1]}
      ]
    ]
  ]
\end{forest}
\end{document}

drei Bäume

Schauen Sie sich die Antwort an, die ich oben verlinkt habe, um Hilfe beim Verständnis der Klammernotation zu erhalten. Sonst wird Ihnen das wie ein Zaubertrick vorkommen und Sie werden es nicht umsetzen können ;).

verwandte Informationen