def recurse(self, full_matrix=False):
for n in self.tree.get_nonterminals(order='<STR_LIT>'):<EOL><INDENT>n_leaves = len(n._ii)<EOL>if full_matrix: M = np.zeros((n_leaves, n_leaves), dtype=float)<EOL>r = np.zeros(n_leaves, dtype=float)<EOL>c_count = <NUM_LIT:0><EOL>for c in n:<EOL><INDENT>ssq = self.branch_variance(c)<EOL>nc = len(c._ii)<EOL>if c.is_terminal():<EOL><INDENT>if full_matrix:<EOL><INDENT>M[c_count, c_count] = <NUM_LIT:1.0>/ssq<EOL><DEDENT>r[c_count] = <NUM_LIT:1.0>/ssq<EOL><DEDENT>else:<EOL><INDENT>if full_matrix:<EOL><INDENT>M[c_count:c_count+nc, c_count:c_count+nc] = c.cinv - ssq*np.outer(c.r,c.r)/(<NUM_LIT:1>+ssq*c.s)<EOL><DEDENT>r[c_count:c_count+nc] = c.r/(<NUM_LIT:1>+ssq*c.s)<EOL><DEDENT>c_count += nc<EOL><DEDENT>if full_matrix: n.cinv = M<EOL>n.r = r <EOL>n.s = n.r.sum()<EOL><DEDENT>
recursion to calculate inverse covariance matrix

Parameters
----------
full_matrix : bool, optional
    if True, the entire inverse matrix is calculated. otherwise, only the weighing vector.