本文整理汇总了Python中simulator.Simulator.plot方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.plot方法的具体用法?Python Simulator.plot怎么用?Python Simulator.plot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulator.Simulator
的用法示例。
在下文中一共展示了Simulator.plot方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Launcher
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import plot [as 别名]
class Launcher(object):
def setup_logging(self):
t = datetime.now()
self.tstamp = '%d-%d-%d-%d-%d' % (t.year, t.month, t.day, t.hour, t.minute)
fname = LOG_FILE_PATH + LOG_FILENAME + self.tstamp + '.log'
logging.basicConfig(filename=fname,level=logging.INFO,format=FORMAT)
def configure(self, p):
print('constructing simulator')
self.sim = Simulator(p['ins'], p['strat'], p['start_date'], p['end_date'], p['open_bal'], self.tstamp)
def simulate(self):
print('running simulator')
start = clock()
self.sim.run()
end = clock()
dur_str = 'seconds = %f' % (end - start)
print(dur_str)
logging.info('sim time = ' + dur_str)
def report(self):
print('plotting')
start = clock()
self.sim.plot()
end = clock()
dur_str = 'seconds = %f' % (end - start)
print(dur_str)
logging.info('plot time = ' + dur_str)
def go(self, p):
self.setup_logging()
self.configure(p)
self.simulate()
self.report()
示例2: run
# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import plot [as 别名]
def run():
if (sys.argv[1] == "-advanced"):
print "Running advanced simulations..."
s = Simulator(2000, [1, 0.5, 0.25, 0.125])
s.simulate(Decoder.SUM_PROD)
s.compute_error()
s.save_results()
s.plot('ro-')
s.save_graph()
s = Simulator(2000, [1, 0.5, 0.25, 0.125])
s.simulate(Decoder.MAX_PROD)
s.compute_error()
s.save_results()
s.plot('g^--')
s.save_graph()
s = Simulator(1000, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
s.simulate(Decoder.SUM_PROD)
s.compute_error()
s.save_results()
s.plot('ro--')
s.save_graph()
s = Simulator(1000, [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0])
s.simulate(Decoder.MAX_PROD)
s.compute_error()
s.save_results()
s.plot('g^--')
s.save_graph()
print "See graphs/advanced-run and stats/advanced-run for detailed results."
else:
print sys.argv
print "Running default simulation at variance levels %(var)s with %(num)s codewords..." % \
{"var": [1, 0.5, 0.25, 0.125],
"num": sys.argv[1]}
s = Simulator(int(sys.argv[1]), [1, 0.5, 0.25, 0.125])
s.default_run()