我正在尝试模拟二维随机游走,方向 0 < θ < 2π 和 T=1000 步。
a=np.zeros((1000,1000))
def randwalk(x,y):
theta=2*math.pi*rd.rand()
x+=math.cos(theta);
y+=math.sin(theta);
return (x,y)
如何将所有中间坐标存储在 a 中?我最初尝试以下形式:
for i in range(1000):
for j in range(1000):
a[i,j] = randwalk(x,y)
但这似乎根本不起作用。