15,916,462 members
1.00/5 (1 vote)
See more:
```#set up the data we will needed
import numpy as np

import matplotlib.pyplot as plt

X0 = 0

T  = 1   #total time

dt = .001 #time steps

N  = int(T/dt) # no of time steps

D  = 1

np.random.seed(1)

t = dt * np.arange(N)

dx = np.sqrt(2 * D * dt)*np.random.randn(N)

x  = np.zeros(N)

for i in range(N-1):
N =100000
x[i+1] = x[i] + dx[i]

plt.plot(t, x )

plt.show()```

What I have tried:

so i want to get repeted multiple curve in it and want to apply for loop . but i don't have idea how to apply this .
Posted
Updated 10-Jan-23 10:49am
CPallini 10-Jan-23 16:36pm
What 'multiple curves' do you want?
Your code produces the graph of the random walk. What else should it produce?

## Solution 1

Do you mean something like this
Python
```#set up the data we will needed
import numpy as np
import matplotlib.pyplot as plt

W = 5 # walkers

X0 = 0

T  = 1   #total time

dt = .001 #time steps

N  = int(T/dt) # no of time steps

D  = 1

np.random.seed(10)

t = dt * np.arange(N)

dx = np.sqrt(2 * D * dt)*np.random.randn(N,W)

x  = np.zeros((N,W))

for w in range(W):
for i in range(N-1):
x[i+1][w] = x[i][w] + dx[i][w]

plt.plot(t, x )

plt.show()```

?