当前位置: 首页>>代码示例>>Python>>正文


Python Probs.toRates方法代码示例

本文整理汇总了Python中cogent.seqsim.usage.Probs.toRates方法的典型用法代码示例。如果您正苦于以下问题:Python Probs.toRates方法的具体用法?Python Probs.toRates怎么用?Python Probs.toRates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cogent.seqsim.usage.Probs的用法示例。


在下文中一共展示了Probs.toRates方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_toRates

# 需要导入模块: from cogent.seqsim.usage import Probs [as 别名]
# 或者: from cogent.seqsim.usage.Probs import toRates [as 别名]
 def test_toRates(self):
     """Probs toRates should return log of probs, optionally normalized"""
     a = Alphabet('abc')**2
     p = Probs([0.9,0.05,0.05,0.1,0.85,0.05,0.02,0.02,0.96], a)
     assert p.isValid()
     r = p.toRates()
     assert isinstance(r, Rates)
     assert r.isValid()
     assert not r.isComplex()
     self.assertEqual(r._data, logm(p._data))
     r_norm = p.toRates(normalize=True)
     self.assertFloatEqual(trace(r_norm._data), -1.0)
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:14,代码来源:test_usage.py

示例2: test_timeForSimilarity

# 需要导入模块: from cogent.seqsim.usage import Probs [as 别名]
# 或者: from cogent.seqsim.usage.Probs import toRates [as 别名]
 def test_timeForSimilarity(self):
     """Rates timeToSimilarity should return correct time"""
     a = self.abc_pairs
     p = Probs([0.75, 0.1, 0.15, 0.2, 0.7, 0.1, 0.05, 0.15, 0.8], a)
     q = p.toRates()
     d = 0.5
     t = q.timeForSimilarity(d)
     x = expm(q._data)(t)
     self.assertFloatEqual(average(diagonal(x), axis=0), d)
     t = q.timeForSimilarity(d, array([1/3.0]*3))
     x = expm(q._data)(t)
     self.assertFloatEqual(average(diagonal(x), axis=0), d)
     self.assertEqual(q.timeForSimilarity(1), 0)
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:15,代码来源:test_usage.py

示例3: test_toSimilarProbs

# 需要导入模块: from cogent.seqsim.usage import Probs [as 别名]
# 或者: from cogent.seqsim.usage.Probs import toRates [as 别名]
    def test_toSimilarProbs(self):
        """Rates toSimilarProbs should match individual steps"""
        a = self.abc_pairs
        p = Probs([0.75, 0.1, 0.15, 0.2, 0.7, 0.1, 0.05, 0.15, 0.8], a)
        q = p.toRates()
        self.assertEqual(q.toSimilarProbs(0.5), \
            q.toProbs(q.timeForSimilarity(0.5)))

        #test a case that didn't work for DNA
        q = Rates(array(
            [[-0.64098451,  0.0217681 ,  0.35576469,  0.26345171],
             [ 0.31144238, -0.90915091,  0.25825858,  0.33944995],
             [ 0.01578521,  0.43162879, -0.99257581,  0.54516182],
             [ 0.13229986,  0.04027147,  0.05817791, -0.23074925]]),
            DnaPairs)
        p = q.toSimilarProbs(0.66)
        self.assertFloatEqual(average(diagonal(p._data), axis=0), 0.66)
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:19,代码来源:test_usage.py

示例4: test_toProbs

# 需要导入模块: from cogent.seqsim.usage import Probs [as 别名]
# 或者: from cogent.seqsim.usage.Probs import toRates [as 别名]
 def test_toProbs(self):
     """Rates toProbs should return correct probability matrix"""
     a = self.abc_pairs
     p = Probs([0.75, 0.1, 0.15, 0.2, 0.7, 0.1, 0.05, 0.1, 0.85], a)
     q = p.toRates()
     self.assertEqual(q._data, logm(p._data))
     p2 = q.toProbs()
     self.assertFloatEqual(p2._data, p._data)
     
     #test a case that didn't work for DNA
     q = Rates(array(
         [[-0.64098451,  0.0217681 ,  0.35576469,  0.26345171],
          [ 0.31144238, -0.90915091,  0.25825858,  0.33944995],
          [ 0.01578521,  0.43162879, -0.99257581,  0.54516182],
          [ 0.13229986,  0.04027147,  0.05817791, -0.23074925]]),
         DnaPairs)
     self.assertFloatEqual(q.toProbs(0.5)._data, expm(q._data)(t=0.5))
开发者ID:GavinHuttley,项目名称:pycogent,代码行数:19,代码来源:test_usage.py


注:本文中的cogent.seqsim.usage.Probs.toRates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。