Click here to Skip to main content
15,902,891 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
actually, I want a gaussian probability distribution curve. so what changes do I have to make in my code for this? please correct my code if anyone has an idea about it. thank you

What I have tried:

#set up the data we will needed
import numpy as np
import matplotlib.pyplot as plt

W = 20 # walkers

X0 = 0

T  = 1   #total time 

dt = .001 #time steps 

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

D  = 1


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 )
Updated 10-Jan-23 22:15pm
Richard Deeming 11-Jan-23 4:24am    
You have already posted this question:
Guassian probability distribution of random walker[^]

The answer won't have changed in the last three hours.

1 solution

It is difficult to understand what you really need.
I guess you have to plot the final positions of the (a conspicuous number of ) walkers in order to get a Gaussian shaped graph.
Share this answer
Astroaspirent 11-Jan-23 5:02am    
yes sir. but how to do it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900