@Zemel-Yang
2017-01-06T16:30:29.000000Z
字数 5425
阅读 1745
python homework
In this final exercise, I choose to discuss Chepter 7, the random system. First, I discuss two simple models, random walk in one dimension with fixed step length and random lengths. Then consider self-avoiding walks and cream-in-your-coffee model and draw the figure of entropy versus time.
A random walk is a mathematical object which describes a path that consists of a succession of random steps. For example, the path traced by a molecule as it travels in a liquid or a gas, the search path of a foraging animal, superstring behavior, the price of a fluctuating stock and the financial status of a gambler can all be approximated by random walk models, even though they may not be truly random in reality. As illustrated by those examples, random walks have applications to many scientific fields including ecology, psychology, computer science, physics, chemistry, and biology, and also to economics. Random walks explain the observed behaviors of many processes in these fields, and thus serve as a fundamental model for the recorded stochastic activity. As a more mathematical application, the value of pi can be approximated by the usage of random walk in agent-based modelling environment.1 The term random walk was first introduced by Karl Pearson in 1905.

1. Random walks
Here I draw the trajectories of a random walker in 2 demention. Code
First, we cosnider a situaion of one dimensional random walk.
The walker begins at the origin, , and the next step is chosen at random to be either right or left, each with probability 1/2. The step length we take is 1(right) or -1(left). I draw the figure 1.
Figure 1 Code
Left: x versus step number ,that is, for two random walks in one dimension. Right: as a function of step number (which is proportional to time) for a collection of one-dimensional randomn walks. The step length was unity and the results for 500 walkers were averaged. The points are the calculated values and the straight red line is a least-squares fit to the form:
3. Random Walks and Diffusion
We know that random walks are equivalent to diffusion. We will adopt the cream-in-your-coffee analogy in which we have a large number of particles (cream) moving in solution (coffee). Calculate the density of particles varies as a function of time we have the diffusion equation:
4. Diffusion, Entropy, and The Arrow of Time
Consider the cream-in-your-coffee problem. Random-walk simulation of diffusion of cream in coffee is shown in figure 9. First we set a number of particle in the center of the whole area which is shaped as a square. Then let them do random walk to up,down,left and right four direction. The only limit is once they are reach the edge of the area they can not pass it. Then we observe the whole random particle picture in different time.
This time, we consider an area of 128*128, and only the center area (16,16) has been occupied by the particle initially. the time sequence for eight subplot is not even. they are (0,10,100,500,1000,2000,4000,8000)
Figure 9 Code
Now its time for us to derive some useful information from this seemingly disordered system. The entropy, to deal with this we have applied a different sumulation method with the above one.
First, we set one particle at the center of the area and let it do the random walk step by step. Each step we will do 5000 times which means there are 5000 particles in the center of the area. Then we add the times of being occupied for every point in this area in 5000 times, so we derive the probability for each state(point) and then use the equation:(the sum is over all point in the area)we get the result.
Figure 10

By exploring several kinds of random walk model,we can say that it is a good approximation for many random system to some extent. It reveals the essence of this kind system in some way. However, to derive the real situation, we can not omit the interaction between the particles. Once we add this factor in into the simulation, there is no doubt that the result will appeal to reality, but just like the SAWs, the calculation will become severely large as the time step increase.
(1) Random walk - Wikipedia
(2) Computational Pythics (Second Edition) - Nicholas J. Giordano, Hisao Nakanishi