# Simulation of random walk

## Description

Random walk model is made to explain the Brownian motion.In this simulation,we assume that there's a group of drunkards(Parameter n1) walking from same area at the same time.Then we can make the following hypothesis:

1) The walking speed is same and they cannot affect each other.

2) The distance of a step they walk is distributed uniformly in a certain range(Parameter n3).

After some walks(Parameter n2), it is obvious that there will be a distribution for the number of drunkards on the plain. In the simulation,each white point stands for a drunkard. What we do is to display the probability density function by simulation.

It can be proved that the distribution is subject to the Weibull distribution. We can see from the simulation that the theoretical function is quite similar with the experimental function, showing the correctness of this model. If you want to know the theoretical model of this simulation, contact the author by email.Seems interesting? Let's go on.

## Parameters input

There are three parameters in the simulation,including n1,n2 and n3.

Parameter n1 stands for the number of drunkards taking part in the simulation.The bigger n1 is,the more accurate the simulation will be.However,the process of simulation becomes slower.

Parameter n2 stands for the number of steps drunkards will walk in a simulation.The bigger n2 is,the slower the simulation will be.

Parameter n3 stands for the maximum distance drunkards walk in one step.

Defult n1,n2 and n3 is set to 1000,1000 and 1.

Note that n1,n2 should always be positive integers and n3 should be positive.Otherwise,it may display error message.

## Start the simulation

The buttom ' Start ' , ' Pause ' , ' Reset ' and the radio buttom ' Show Animation ' is used in the process of simulation.

After you put in the valid parameters in the ' Parameters ' group,you can click on the ' Start ' buttom and the simulation is on the way.

Choose the 'Show Progress'radio buttom to show the progress of simulation and choose ' Show Animation ' radio buttom to show the process of simulation.The progress of the simulation can be seen just above the ' Parameter ' group.

Although ' Show Progress ' and ' Show Animation ' radio buttom shows the progress and process of simultion vividly, it is suggested that you unchoose these two buttoms to improve efficiency.

If you unchoose ' Show Progress ',the message ' Please wait ... ' will appear so that you know the process is going on. When the simulation is over, a message box will appear telling you that the simulation process is over.

The simulation can be paused by clicking on the ' Pause ' buttom and the buttom message is changed to ' Continue '.You can get the current statistical result using ' Tools ' group. To continue the simulation,click on the 'Continue' buttom where it is previously the ' Pause ' buttom.

If one simulation is finished and you want to go on another simulation,press ' Reset ' buttom and the windows is reset to its initial state.Before you go on another simulation,you can adjust the input in the ' Parameter 'group and compare the results.

## Get the statistical result

When the simulation is over,next step is to show the result of the distribution on the axis.

Turn to the right region of the figure.Click on the ' Plot Data ' buttom and you will get the scatters on the ' r-f(r) ' axis.

To fit the data,just click on ' Fit Curve ' buttom and you will get the fitting curve in the ' r-f(r) ' axis.Also the expression of ' fitting curve ' is shown in the ' Fitting Curve 'group.

Each simulation has a theory curve.Click on the 'Theory Curve' and you will get it immediately both in the axis and ' Fitting Results ' group.

You can click on these three buttoms one by one.Each result has its legends on the axis.

Finally,you can get R-square and RMSE of the fitting in the ' Fitting Results ' group.

Different parameter n2 would cause different results,so you can first click on the ' Pause ' buttom and then click on the ' Theory Curve ' to compare what the difference would be.

If you are not satisfied with the results shown in the axis,just click on the ' Clear Plot ' and the axis is reset to its initial state.

However,if you haven't started simulation before using the Tools group to plot data and generate distribution curve,it will display a warning message.

## Change the color of curve

The default color for the scatters,Fitting Curve and Theory Curve is green,blue and red.You can change the color as you like.Click on the ' Edit ' menu and then in the submenu of ' Color ',you can see ' Scatters ' , ' Fitting Curve ' , ' Theory Curve ' and ' Set Default ' .

Click on one of them, and you can change the color of what you have chosen.

However,it may display some error message if there are no scatters or curve on the axis.

## Save the picture and data

The picture can be saved as jpg,eps,emf,bmp,fig format and the data can be saved as xls and xlsx format.

To save the simulation picture,click on the File menu and select ' Save_LeftPicture '.

To save the figure of statistical result, click on the File menu and select ' Save_RightPicture '.

To save data,click on the File menu and select ' Save_Data '.

## Exit the program

To exit the program,click on the File menu and select ' Exit '.

## Author

The model and the program are designed by QiQin Zhan, from Shanghai Jiao Tong University.

If you have further questions or detect some bugs about the program,it is warmly welcomed for a further discussion.

Email:dyxsdxwx@163.com.