def __init__(self, tree_in, tip_value = None,<EOL>branch_value = None, branch_variance = None):
super(TreeRegression, self).__init__()<EOL>self.tree = tree_in<EOL>for li, l in enumerate(self.tree.get_terminals()):<EOL><INDENT>l._ii = np.array([li])<EOL><DEDENT>total_bl = <NUM_LIT:0><EOL>for n in self.tree.get_nonterminals(order='<STR_LIT>'):<EOL><INDENT>n._ii = np.concatenate([c._ii for c in n])<EOL>n._ii.sort()<EOL>for c in n:<EOL><INDENT>c.up=n<EOL>total_bl+=c.branch_length<EOL><DEDENT><DEDENT>self.tree.root.up=None<EOL>self.N = self.tree.root._ii.shape[<NUM_LIT:0>]<EOL>if tip_value is None:<EOL><INDENT>self.tip_value = lambda x:np.mean(x.numdate) if x.is_terminal() else None<EOL><DEDENT>else:<EOL><INDENT>self.tip_value = tip_value<EOL><DEDENT>if branch_value is None:<EOL><INDENT>self.branch_value = lambda x:x.branch_length<EOL><DEDENT>else:<EOL><INDENT>self.branch_value = branch_value<EOL><DEDENT>if branch_variance is None:<EOL><INDENT>self.branch_variance = lambda x:x.branch_length + <NUM_LIT>*total_bl/self.N<EOL><DEDENT>else:<EOL><INDENT>self.branch_variance = branch_variance<EOL><DEDENT>
Parameters
----------
 T : (Bio.Phylo.tree)
    Tree for which the covariances and regression
    are to be calculated.

 tip_value : (callable)
    function that for each tip returns the value to
    be used in the regression.

 branch_value : (callable)
    function that for each node of the tree returns
    the contribution of this branch to the value of
    the subtending tips.

 variance_function : (callable)
    function that for each node of the tree returns
    the accumulated variance