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


Python Arduino.meanrand方法代码示例

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


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

示例1: Arduino

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import meanrand [as 别名]
#coding: utf-8
"""Just a short program that grabs a bitstring s and writes to a file or whatever"""

from arduino import Arduino
from stattests import StatTests
from sys import stdin, argv

ard = Arduino()
# FIPS 140-1 demands a bitstring s of length 20 000. 
# l = 20000
l = 1000

s = ''.join([a for a in ard.meanrand(l)])
st = StatTests(s)
print st.monobit()

# File stuff
# fname = argv[1] if len(argv) > 1 else 's.txt'
# f = open(fname, 'w')
# s = ''.join([a for a in ard.meanrand(l)])
# f.write(s)
# f.close()


开发者ID:benediktkr,项目名称:ardrand,代码行数:24,代码来源:grabrndbit.py

示例2: len

# 需要导入模块: from arduino import Arduino [as 别名]
# 或者: from arduino.Arduino import meanrand [as 别名]
import sys

if len(sys.argv) == 1:
    print "missing alg"
    sys.exit()
    
algorithm = sys.argv[1]
k = int(sys.argv[2])
ard = Arduino()

print algorithm

# ...
if algorithm == 'meanrand':
    s = ''.join(ard.meanrand(k))
elif algorithm == 'updownrand':
    s = ''.join(ard.updownrand(k))
elif algorithm == 'mix':
    s = ''.join(ard.mixmeanupdown(k))
elif algorithm == 'leastsig':
    s = ''.join(ard.leastsigrand(k))
elif algorithm == 'twol':
    s = ''.join(ard.twoleastsignrand(k))

elif algorithm == 'vanilla':
    s = ''.join(ard.vanilla(k))

if "-p" in sys.argv:
    print s
开发者ID:benediktkr,项目名称:ardrand,代码行数:31,代码来源:get20k.py


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