本文整理汇总了Python中cogent.core.profile.Profile.randomIndices方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.randomIndices方法的具体用法?Python Profile.randomIndices怎么用?Python Profile.randomIndices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cogent.core.profile.Profile
的用法示例。
在下文中一共展示了Profile.randomIndices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_randomIndices
# 需要导入模块: from cogent.core.profile import Profile [as 别名]
# 或者: from cogent.core.profile.Profile import randomIndices [as 别名]
def test_randomIndices(self):
"""randomIndices: 99% of new frequencies should be within 3*SD
"""
r_num, c_num = 100, 20
num_elements = r_num * c_num
r = random([r_num, c_num])
p = Profile(r, "A" * c_num)
p.normalizePositions()
d = p.Data
n = 1000
# Test only works on normalized profile, b/c of 1-d below
means = n * d
three_stds = sqrt(d * (1 - d) * n) * 3
result = [p.randomIndices() for x in range(n)]
a = Alignment(transpose(result))
def absoluteProfile(alignment, char_order):
f = a.columnFreqs()
res = zeros([len(f), len(char_order)])
for row, freq in enumerate(f):
for i in freq:
res[row, ord(i)] = freq[i]
return res
ap = absoluteProfile(a, p.CharOrder)
failure = abs(ap - means) > three_stds
assert sum(sum(failure)) / num_elements <= 0.01