Discussion:
Package to do probability trees?
(too old to reply)
Ronald Bruck
2006-12-13 21:01:28 UTC
Permalink
A probability tree has a number of nodes and branches; along the
branches one prints the probability (preferably rotated to match the
branch). One also has labels for the nodes.

It would seem to be perfect for a recursive implementation. It's not
hard to do manually in the picture environment; is there a package
already designed for this? (I mostly use LaTeX.) Perhaps I'm missing
a more capable package which does a lot more (this happens a lot).

-- Ron Bruck
vanvera
2006-12-13 22:01:08 UTC
Permalink
Post by Ronald Bruck
A probability tree has a number of nodes and branches; along the
branches one prints the probability (preferably rotated to match the
branch). One also has labels for the nodes.
It would seem to be perfect for a recursive implementation. It's not
hard to do manually in the picture environment; is there a package
already designed for this? (I mostly use LaTeX.) Perhaps I'm missing
a more capable package which does a lot more (this happens a lot).
-- Ron Bruck
With the package pgf/tikz one can draw trees recursively and do a lot of
other things quite easily:
<http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=pgf>
both in latex and in pdflatex. Have a look at the manual
to see some stunning example.

g.
Kjell Magne Fauske
2006-12-14 12:50:15 UTC
Permalink
An example of a probability tree made with PGF/TikZ can be found at:
http://www.fauskes.net/pgftikzexamples/probability-tree/

The tree syntax of TikZ is clean and flexible. The example uses rotated
labels just to show how to do this with PGF/TikZ. Personally I think
upright labels is better in this case.

The recursive implementation suggested by Jean-C�me Charpentier looks
very interesting, by the way. Nice work.

Regards,
Kjell Magne Fauske
Post by vanvera
Post by Ronald Bruck
A probability tree has a number of nodes and branches; along the
branches one prints the probability (preferably rotated to match the
branch). One also has labels for the nodes.
It would seem to be perfect for a recursive implementation. It's not
hard to do manually in the picture environment; is there a package
already designed for this? (I mostly use LaTeX.) Perhaps I'm missing
a more capable package which does a lot more (this happens a lot).
-- Ron Bruck
With the package pgf/tikz one can draw trees recursively and do a lot of
<http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=pgf>
both in latex and in pdflatex. Have a look at the manual
to see some stunning example.
g.
Dan
2006-12-14 00:34:28 UTC
Permalink
Post by Ronald Bruck
A probability tree has a number of nodes and branches; along the
branches one prints the probability (preferably rotated to match the
branch).
I would strongly prefer NOT rotated, but rather upright, for
readability.
Consider your poor readers before printing anything rotated.


Dan
h***@mdh.se
2006-12-14 10:21:24 UTC
Permalink
Post by Ronald Bruck
A probability tree has a number of nodes and branches; along the
branches one prints the probability (preferably rotated to match the
branch). One also has labels for the nodes.
It would seem to be perfect for a recursive implementation. It's not
hard to do manually in the picture environment; is there a package
already designed for this? (I mostly use LaTeX.) Perhaps I'm missing
a more capable package which does a lot more (this happens a lot).
Check out pstricks. The tree-drawing possibilities are huge! Expect
a somewhat steep learning curve; there is lots of stuff in pstricks,
and it takes a while to develop a feeling for it.

Hillevi Gavel
Department of mathematics and physics
M�lardalens h�gskola
Sweden
Jean-Côme Charpentier
2006-12-14 11:56:47 UTC
Permalink
Post by h***@mdh.se
Post by Ronald Bruck
A probability tree has a number of nodes and branches; along the
branches one prints the probability (preferably rotated to match the
branch). One also has labels for the nodes.
It would seem to be perfect for a recursive implementation. It's not
hard to do manually in the picture environment; is there a package
already designed for this? (I mostly use LaTeX.) Perhaps I'm missing
a more capable package which does a lot more (this happens a lot).
Check out pstricks. The tree-drawing possibilities are huge! Expect
a somewhat steep learning curve; there is lots of stuff in pstricks,
and it takes a while to develop a feeling for it.
Indeed!
I don't know what you search for exactly. Are these examples close to
your wish?
<http://melusine.eu.org/syracuse/pstricks/20060429-jcc/>
(Sorry for the french comments.)

Jean-Côme Charpentier
Edward M. Reingold
2006-12-14 13:50:12 UTC
Permalink
RB> A probability tree has a number of nodes and branches; along the
RB> branches one prints the probability (preferably rotated to match the
RB> branch). One also has labels for the nodes.


Here is an example of such a tree, using pstricks, from a recent paper of
mine.

\documentclass{article}
\usepackage{pst-all}

\makeatletter

\psset{xunit=10mm,yunit=10mm,arrows=->}
\psset{treemode=R,levelsep=2.75cm,treesep=1.5cm,framesep=1pt}

\def\unequal#1#2{\ncput*{$\neq$}\tbput*{$\frac{#1}{#2}$}}
\def\equal#1#2{\ncput*{$=$}\taput*{$\frac{#1}{#2}$}}

\def\ghost#1{=#1}% Indicator of a ghost set

\def\notriple{%
\begin{pspicture}(-6pt,-6pt)(6pt,6pt)%
\rput(0,0){$\emptyset$}
\end{pspicture}}

\def\firstchar#1{\@firstchar #1\@END}
\def\@firstchar #1#2\@END{#1}
\def\lastchars#1{\@lastchar #1\@END}
\def\@lastchar#1#2\@END{#2}
\makeatother

\def\labeledmonad#1#2#3{%
\begin{pspicture}(-0.25pt,-2pt)(0.25pt,6.25pt)%
\psset{linestyle=solid}
\if-\firstchar{#3}% Deficit set
\ovalnode[fillstyle=solid,fillcolor=lightgray]%
{#1}{\scriptsize $#3$}\hspace{2pt} #2%
\else\if=\firstchar{#3}% It's a ghost set
\circlenode[linecolor=gray]%
{#1}{\gray\scriptsize $\lastchars#3$}%
\hspace{2pt} #2%
\else%
\circlenode{#1}{\scriptsize $#3$}\hspace{2pt} #2%
\fi\fi%
\end{pspicture}}
\def\monad#1#2{\labeledmonad{#1}{}{#2}}


\def\labeleddyad#1#2#3#4#5{%
\begin{pspicture}(-0.5,-0.8)(0.5,0.8)%
\rput(-0.25,-0.5){\monad{#1a}{#3}}%
\uput{8pt}[180](-0.25,-0.5){#2}%
\rput(0.25,0.5){\monad{#1b}{#5}}%
\uput{8pt}[180](0.25,0.5){#4}%
\ncline{-}{#1a}{#1b}%
\end{pspicture}}

\def\dyad#1#2#3{\labeleddyad{#1}{}{#2}{}{#3}}

\begin{document}

\pstree{\Tr{\dyad{A}{m}{2m}\dyad{B}{m}{2m}}%
\ncline[linestyle=dashed]{-}{Aa}{Ba}}%
{\pstree{\Tr{\dyad{C}{2m}{2m}\monad{D}{2m}}\equal{1}{3}
\ncline{-}{Cb}{D}
\ncline[linestyle=dashed]{-}{Ca}{D}}%
{\Tr{\dyad{E}{2m}{4m}}\equal{1}{2}%
\Tr{\notriple}\unequal{1}{2}}
\pstree{\Tr{\dyad{F}{m}{2m}\dyad{G}{m}{2m}}\unequal{2}{3}
\ncline{-}{Fa}{Ga}
\ncline[linestyle=dashed]{-}{Fa}{Gb}}
{\pstree{\Tr{\dyad{H}{2m}{3m}\monad{I}{m}}\equal{1}{2}
\ncline{-}{Hb}{I}
\ncline[linestyle=dashed]{-}{Ha}{I}}
{\Tr{\dyad{J}{3m}{3m}}\equal{1}{2}
\Tr{\dyad{K}{m}{2m}}\unequal{1}{2}}
\pstree{\Tr{\dyad{L}{m}{2m}\dyad{M}{m}{2m}}\unequal{1}{2}
\ncline{-}{La}{Ma}
\ncline{-}{La}{Mb}
\ncline[linestyle=dashed]{-}{Lb}{Mb}}
{\Tr{\monad{N}{3m}}\equal{1}{2}
\Tr{\dyad{O}{m}{2m}}\unequal{1}{2}}}}

\end{document}
--
Professor Edward M. Reingold Email: ***@iit.edu
Department of Computer Science Voice: (312) 567-3309
Illinois Institute of Technology Assistant: (312) 567-5152
Stuart Building Fax: (312) 567-5067
10 West 31st Street, Suite 236
Chicago, IL 60616-3729 U.S.A.
Continue reading on narkive:
Loading...