@staticmethod<EOL><INDENT>def coaltree(ntips, ne=None, seed=None):<DEDENT>
<EOL>random.seed(seed)<EOL>coalunits = False<EOL>if not ne:<EOL><INDENT>coalunits = True<EOL>ne = <NUM_LIT><EOL><DEDENT>tips = [<EOL>toytree.tree().treenode.add_child(name=str(i)) <EOL>for i in range(ntips)<EOL>]<EOL>while len(tips) > <NUM_LIT:1>:<EOL><INDENT>rtree = toytree.tree()<EOL>tip1 = tips.pop(random.choice(range(len(tips))))<EOL>tip2 = tips.pop(random.choice(range(len(tips))))<EOL>kingman = (<NUM_LIT> * ne) / float(ntips * (ntips - <NUM_LIT:1>))<EOL>dist = random.expovariate(<NUM_LIT:1.> / kingman)<EOL>rtree.treenode.add_child(tip1, dist=tip2.height + dist)<EOL>rtree.treenode.add_child(tip2, dist=tip1.height + dist)<EOL>tips.append(rtree.treenode)<EOL><DEDENT>self = toytree.tree(tips[<NUM_LIT:0>].write())    <EOL>self.treenode.ladderize()<EOL>if coalunits:<EOL><INDENT>for node in self.treenode.traverse():<EOL><INDENT>node.dist /= (<NUM_LIT> * ne)<EOL><DEDENT><DEDENT>for node in self.treenode.traverse():<EOL><INDENT>if node.is_leaf():<EOL><INDENT>node.dist += node.height<EOL><DEDENT><DEDENT>for tip in self.get_tip_labels():<EOL><INDENT>node = self.treenode.search_nodes(name=tip)[<NUM_LIT:0>]<EOL>node.name = "<STR_LIT>".format(node.name)<EOL><DEDENT>self._coords.update()<EOL>return self<EOL>
Returns a coalescent tree with ntips samples and waiting times 
between coalescent events drawn from the kingman coalescent:
(4N)/(k*(k-1)), where N is population size and k is sample size.
Edge lengths on the tree are in generations.

If no Ne argument is entered then edge lengths are returned in units
of 2*Ne, i.e., coalescent time units.