]> git.donarmstrong.com Git - ape.git/blob - man/howmanytrees.Rd
cd98f7cec3a941b15f4cbabd897d7efb7acd76cc
[ape.git] / man / howmanytrees.Rd
1 \name{howmanytrees}
2 \alias{howmanytrees}
3 \title{Calculate Numbers of Phylogenetic Trees}
4 \usage{
5 howmanytrees(n, rooted = TRUE, binary = TRUE,
6              labeled = TRUE, detail = FALSE)
7 }
8 \arguments{
9   \item{n}{a positive numeric integer giving the number of tips.}
10   \item{rooted}{a logical indicating whether the trees are rooted
11     (default is \code{TRUE}).}
12   \item{binary}{a logical indicating whether the trees are bifurcating
13     (default is \code{TRUE}).}
14   \item{labeled}{a logical indicating whether the trees have tips
15     labeled (default is \code{TRUE}).}
16   \item{detail}{a logical indicating whether the eventual intermediate
17     calculations should be returned (default is \code{FALSE}). This
18     applies only for the multifurcating trees, and the bifurcating,
19     rooted, unlabeled trees (aka tree shapes).}
20 }
21 \description{
22   This function calculates the number of possible phylogenetic trees for
23   a given number of tips.
24 }
25 \details{
26   In the cases of labeled binary trees, the calculation is done directly
27   and a single numeric value is returned.
28
29   For multifurcating trees, and bifurcating, rooted, unlabeled trees,
30   the calculation is done iteratively for 1 to \code{n} tips. Thus the
31   user can print all the intermediate values if \code{detail = TRUE}, or
32   only a single value if \code{detail = FALSE} (the default).
33
34   For multifurcating trees, if \code{detail = TRUE}, a matrix is
35   returned with the number of tips as rows (named from \code{1} to
36   \code{n}), and the number of nodes as columns (named from \code{1} to
37   \code{n - 1}). For bifurcating, rooted, unlabeled trees, a vector is
38   returned with names equal to the number of tips (from \code{1} to
39   \code{n}).
40
41   The number of unlabeled trees (aka tree shapes) can be computed only
42   for the rooted binary cases.
43
44   Note that if an infinite value (\code{Inf}) is returned this does not
45   mean that there is an infinite number of trees (this cannot be if the
46   number of tips is finite), but that the calculation is beyond the
47   limits of the computer.
48 }
49 \value{
50   a single numeric value, or in the case where \code{detail = TRUE} is
51   used, a named vector or matrix.
52 }
53 \references{
54   Felsenstein, J. (2004) \emph{Inferring phylogenies}. Sunderland:
55   Sinauer Associates.
56 }
57 \author{Emmanuel Paradis \email{Emmanuel.Paradis@mpl.ird.fr}}
58 \examples{
59 ### Table 3.1 in Felsenstein 2004:
60 for (i in c(1:20, 30, 40, 50))
61   cat(paste(i, howmanytrees(i), sep = "\t"), sep ="\n")
62 ### Table 3.6:
63 howmanytrees(8, binary = FALSE, detail = TRUE)
64 }
65 \keyword{arith}
66 \keyword{math}