【发布时间】:2021-06-03 08:25:15
【问题描述】:
我有在 Python 中生成少数游戏模型的代码。我正在为具有单个值的参数运行我的代码,例如N = 101,它工作正常,但我希望能够为同一参数的多个值运行它,例如N = 101,201,301。我不能只设置一个列表,因为我的代码有很多 numpy 数组,所以需要匹配我所有的数组等。 我现在已经将我的代码存储到一个函数中:
def mg_theory(N,time, S, M):
# index to how we pick out a strategy
index = 1 - 2 * np.random.rand(N, M, S)
# allocating strategy randomly to all players for past m weeks
# each strategy is different for all players, each number corresponds to a different strategy
# some may have same strategy
outcomes = np.random.rand(N, S)
# guess randomly how many people are going for first m weeks
history = np.random.randint(0, N, size=2 * M)
history = np.reshape(history, (history.shape[0], 1))
....
etc
(rest of code)
如您所见,我有 4 个参数,其中 2 个(N 和 M)我希望有多个值。 有人知道吗?
【问题讨论】:
标签: python function modeling game-theory