首页 > 解决方案 > 在python中生成随机数流

问题描述

我正在尝试在 python 中为模拟模型生成一个唯一随机数流。我想运行模拟 100 次,即 100 次。这是我尝试过的

    s=Simulation()
    for i in range(100):         #performs 100 simulation runs
        np.random.seed(i)
        while s.clock <= 240:    #runs the simulation model for 240 minutes
            s.time_adv()  
        print(s.num_arrival)     #print the number of arrivals in in each simulation run

这是我每次得到的输出

85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,

我希望每次模拟运行,在 100 次运行中,都有一个唯一的随机数序列

标签: pythonnumpyrandomsimulationrandom-seed

解决方案


推荐阅读