似乎您稍后在代码中遇到问题...(例如,收集统计信息时)。检查以下较小的代码段:
import random, collections
data = collections.defaultdict(int)
for x in range(1000000):
data[round(random.random(),1)] += 1
print(data)
你会看到,0
和1
当然有关于都是非常均匀的其他值的一半的样品。
例如,我得到了:
defaultdict(<class 'int'>,
{0.4: 100083,
0.9: 99857,
0.3: 99892,
0.8: 99586,
0.5: 100108,
1.0: 49874, # Correctly about half the others
0.7: 100236,
0.2: 99847,
0.1: 100251,
0.6: 100058,
0.0: 50208}) # Correctly about half the others
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句