當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。