def test_nodelikelihood_2tiptreeSymmetricQ2x2difblens_returnslikelihood(self): charstates = self.charstates_01 tree = self.simpletreedifblens for i, node in enumerate(tree.leaves()): node.charstate = charstates[i] Q = self.Q2x2_sym t = [ node.length for node in tree.descendants() ] t = np.array(t, dtype=np.double) p = cyexpokit.dexpm_tree(Q,t) for i, node in enumerate(tree.descendants()): node.pmat = p[i] node = tree predictedLikelihood = 0.22559418195297778 calculatedLikelihood = discrete.nodeLikelihood(node) self.assertTrue(np.isclose(predictedLikelihood, calculatedLikelihood))
def test_nodelikelihood_2tiptreeSymmetricQ2x2_returnslikelihood(self): charstates = self.charstates_01 tree = self.simpletree for i, node in enumerate(tree.leaves()): node.charstate = charstates[i] Q = self.Q2x2_sym t = [node.length for node in tree.descendants()] t = np.array(t, dtype=np.double) p = cyexpokit.dexpm_tree(Q, t) for i, node in enumerate(tree.descendants()): node.pmat = p[i] node = tree predictedLikelihood = 0.16483997131 calculatedLikelihood = discrete.nodeLikelihood(node) self.assertTrue(np.isclose(predictedLikelihood, calculatedLikelihood))
def test_nodelikelihood_2tiptreesinglenodeSymmetricQ3x3_returnslikelihood(self): charstates = self.charstates_01 tree = self.simpletree for i, node in enumerate(tree.leaves()): node.charstate = charstates[i] Q = self.Q3x3_sym t = [ node.length for node in tree.descendants() ] t = np.array(t, dtype=np.double) p = cyexpokit.dexpm_tree(Q,t) for i, node in enumerate(tree.descendants()): node.pmat = p[i] node = tree predictedLikelihood = 0.0863939177214389 calculatedLikelihood = discrete.nodeLikelihood(node) self.assertTrue((predictedLikelihood, calculatedLikelihood))