我想让我的代码更快地运行,以进行更多的迭代和运行。现在,我的代码太慢了,但是我不知道要更改什么来加速它。我首先编写了动力学的蒙特卡洛模拟,然后将其编辑为布朗运动模拟。我当前的代码无法处理10,000次运行,每次运行10,000次迭代。
import numpy as np
import matplotlib.pyplot as plt
import time
%matplotlib inline
runs = int(input("Enter number of runs: "))
N = int(input("Enter number of iterations per simulation: "))
y = 0
R = 10*1 # R is the rate value
t0 = time.time()
for y in range(runs): # Run the simulation 'runs' times
T = np.array([0])
dt = 0
x = 0.5 # sets values
X = np.array([x])
t = 0
i = 0
while t < N: # …Run Code Online (Sandbox Code Playgroud)