You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to fix this answer. please help. I think it has something to do with my arrays.
import numpy as np
import random as rand
import matplotlib.pyplot as plt
particles = 10
steps = 20
position = np.zeros(particles) # position of particles start at zero
right = 1; left = 2 # assign values to left and right positions
for step in range(steps):
for p in range(particles):
walk = rand.randint(1,2)
if walk == right:
position[p] += 1
elif walk == left:
position[p] -=1
displacement = position-0
print(position)
plt.plot(steps,displacement)
The text was updated successfully, but these errors were encountered:
I am trying to fix this answer. please help. I think it has something to do with my arrays.
import numpy as np
import random as rand
import matplotlib.pyplot as plt
particles = 10
steps = 20
position = np.zeros(particles) # position of particles start at zero
right = 1; left = 2 # assign values to left and right positions
for step in range(steps):
for p in range(particles):
walk = rand.randint(1,2)
if walk == right:
position[p] += 1
elif walk == left:
position[p] -=1
displacement = position-0
print(position)
plt.plot(steps,displacement)
The text was updated successfully, but these errors were encountered: