Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: x and y must have same first dimension, but have shapes (1,) and (10,) #124

Open
atdortch opened this issue Sep 27, 2018 · 0 comments

Comments

@atdortch
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant