Home / Expert Answers / Computer Science / data-science-class-with-python1-plot-the-random-walk-in-two-dimensions-include-relevant-text-about-pa883

(Solved): Data Science class with Python1:Plot the random walk in two dimensions. Include relevant text about ...



Data Science class with Python

1:Plot the random walk in two dimensions. Include relevant text about the walk that is included in the visual.
2: Create a function that calculates the distance between the starting point and each step in a random walk. A list (or array) of distances should be generated as a result. Plot these distance data against the number of steps. Make sure the plot has the proper labels.
3: Discover a method to calculate and gather the step size, or the length of each step in the random walk. The result of this should be a list (or array) of lengths. Graph the distribution of distances as a histogram. Make sure the graphic is labeled accurately and that you use good bin sizes.

I have some code for this assignment but have not completed yed(especially 2 and 3).

I would be happy if you could give me some code for them :)

---

Code

point = np.array([0,0])

history = []

history.append(point)

for i in range(1000):

step = 2*np.random.rand(2)-1

point=point + step

history.append(point)

history = np.array(history)

x=history[:,0]

y=history[:,1]

print(x)

print(y)

p = plt.scatter(x,y,s=5)

p = plt.plot(x,y)

plt.show()

Result

[ 0. -0.54780343 -0.69746769 ... -2.74527817 -3.06505516 -2.9942981 ]

[ 0. 0.68141436 0.22991698 ... -28.0273461 -27.3523717 -28.14853068]



We have an Answer from Expert

View Expert Answer

Expert Answer



We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe