# Sidebar. A random walk

A random walk

(Relevant to escape of gamma energy from core of Sun, and to tumbling microbes in water)

Many particles – gamma photons in the Sun’s core, dye molecules or pollen grains dropped into water, perfume molecules from a bottle opened in still air – move with apparent randomness in the directions in which they move anew after collisions. While the equations of classical mechanics have the motion as being deterministic and knowable, “knowable” would mean having data on something like Avogadro’s number of particles – not possible. The origins of randomness go deeper than that, even in classical mechanics and more so in quantum mechanics. It generally suffices to regard many of these motions as random, even if with some average biases in direction.

Random displacements still have some strong patterns, including in their averages. For an unbiased random walk by many particles in a group (an ensemble, a repetition of starts), the average over all the members (if a large number is considered) is no displacement. On the other hand, individual particles to end up at significant distances in any direction. That’s the basis of diffusion. On average the dye molecules are still at the center but individuals are at distances that increase over time, in fact, as the square root of the time.

Almost all physical examples occur in three dimensions. Still, a one-dimensional simulation is illustrative. Let a particle move on a grid of positions that are evenly spaced, to the left and to the right. Let the particle take N steps. Each step is chosen randomly to be to the left or to the right. We can do this by throwing an unbiased die and moving left on odd numbers and right on even numbers. We can save time and noise by letting a computer provide (pseudo)random numbers. I say pseudo because computers have a finite number of states, even if this be in the quadrillions. The quibbling may be left if we want to examine a few thousand or a few million steps. Any computer will have a program or an app that will provide “random” numbers (and I’ll leave off the quotes now) that are equally distributed over the range of real numbers between 0 and 1. If the number is 0.5 of less, move left, else, move right. (We also won’t quibble over open and closed intervals, which differ insignificantly over a million steps with resolutions of 32 or 64 bits.)

I present two programs written in Python 3.7. One allows the user to select the number of particles to track and the number of steps each particle takes. It then accumulates a plot, showing how many of the particles ended up at various positions (stuffed into a number of bins, each bin being a range of distances). Here are three plots at various stages. It’s clear that that the average displacement is near zero and the probability of a given displacement falls off quickly from zero.

The program also reports the mean value of the square of the displacement (which turns out be just the number of steps, nicely) and the average displacement (nearly zero):

E:\vince\lca\science_5-8_2019-20>python3 ranwalk_w_bins.py

Enter number of runs =< 1000 1000

Enter number of steps 300

Enter number of bins to use =< 50, and even 50

xminuse= -43.30127018922194 , span= 86.60254037844388 , binwidth= 2

mean x2= 298.156 mean x= -0.102

Overall xmin= -60.0 , xmax= 56.0

Another program follows an individual particle, creating a cumulative movie of its progress by recording each new position on a new line above:

There is a clear predominance of left-wise steps. Such a net + or – value is common in a sequence of random numbers. It’s a trait that leads to the ruin of many gamblers. There’s no expectation of compensating for a run of heads in a coin toss with an enhanced probability of tails. The probability of each step is independent of the result of the last step.

Clearly, diffusion to long distances takes a prohibitively long time. If an ensemble reaches a root mean square distance or rms (as sqrt(<x2>) of, say, 20 in a unit time, say, a second, it will take 100 times longer to reach an rms of 200 and 10,000 times longer to reach an rms of 2,000. Diffusion is great at short distances, such as micrometers for biochemicals to diffuse inside a living cell, but impossibly slow for long distances such as from head to toe of a person, about a million times greater. Suppose the diffusivity of a biomolecule of modest size in a protein-crowded cell interior is about 1/50th that for self-diffusion of water, or about 5×10-11 m2s-1. The time to move 1 meter would be about, or about 28 hours. Thus, we need a circulatory system.

In the main text I reprised the calculation of 370,000 years for a photon moving at the speed of light between collisions to make it from the Sun’s core to the surface. Stars of our Sun’s size have circulation only at the edges. Bigger, hotter stars have large convective zones.

A random walk

(Relevant to escape of gamma energy from core of Sun, and to tumbling microbes in water)

Many particles – gamma photons in the Sun’s core, dye molecules or pollen grains dropped into water, perfume molecules from a bottle opened in still air – move with apparent randomness in the directions in which they move anew after collisions. While the equations of classical mechanics have the motion as being deterministic and knowable, “knowable” would mean having data on something like Avogadro’s number of particles – not possible. The origins of randomness go deeper than that, even in classical mechanics and more so in quantum mechanics. It generally suffices to regard many of these motions as random, even if with some average biases in direction.

Random displacements still have some strong patterns, including in their averages. For an unbiased random walk by many particles in a group (an ensemble, a repetition of starts), the average over all the members (if a large number is considered) is no displacement. On the other hand, individual particles to end up at significant distances in any direction. That’s the basis of diffusion. On average the dye molecules are still at the center but individuals are at distances that increase over time, in fact, as the square root of the time.

Almost all physical examples occur in three dimensions. Still, a one-dimensional simulation is illustrative. Let a particle move on a grid of positions that are evenly spaced, to the left and to the right. Let the particle take N steps. Each step is chosen randomly to be to the left or to the right. We can do this by throwing an unbiased die and moving left on odd numbers and right on even numbers. We can save time and noise by letting a computer provide (pseudo)random numbers. I say pseudo because computers have a finite number of states, even if this be in the quadrillions. The quibbling may be left if we want to examine a few thousand or a few million steps. Any computer will have a program or an app that will provide “random” numbers (and I’ll leave off the quotes now) that are equally distributed over the range of real numbers between 0 and 1. If the number is 0.5 of less, move left, else, move right. (We also won’t quibble over open and closed intervals, which differ insignificantly over a million steps with resolutions of 32 or 64 bits.)

I present two programs written in Python 3.7. One allows the user to select the number of particles to track and the number of steps each particle takes. It then accumulates a plot, showing how many of the particles ended up at various positions (stuffed into a number of bins, each bin being a range of distances). Here are three plots at various stages. It’s clear that that the average displacement is near zero and the probability of a given displacement falls off quickly from zero.

The program also reports the mean value of the square of the displacement (which turns out be just the number of steps, nicely) and the average displacement (nearly zero):

E:\vince\lca\science_5-8_2019-20>python3 ranwalk_w_bins.py

Enter number of runs =< 1000 1000

Enter number of steps 300

Enter number of bins to use =< 50, and even 50

xminuse= -43.30127018922194 , span= 86.60254037844388 , binwidth= 2

mean x2= 298.156 mean x= -0.102

Overall xmin= -60.0 , xmax= 56.0

Another program follows an individual particle, creating a cumulative movie of its progress by recording each new position on a new line above:

There is a clear predominance of left-wise steps. Such a net + or – value is common in a sequence of random numbers. It’s a trait that leads to the ruin of many gamblers. There’s no expectation of compensating for a run of heads in a coin toss with an enhanced probability of tails. The probability of each step is independent of the result of the last step.

Clearly, diffusion to long distances takes a prohibitively long time. If an ensemble reaches a root mean square distance or rms (as sqrt(<x2>) of, say, 20 in a unit time, say, a second, it will take 100 times longer to reach an rms of 200 and 10,000 times longer to reach an rms of 2,000. Diffusion is great at short distances, such as micrometers for biochemicals to diffuse inside a living cell, but impossibly slow for long distances such as from head to toe of a person, about a million times greater. Suppose the diffusivity of a biomolecule of modest size in a protein-crowded cell interior is about 1/50th that for self-diffusion of water, or about 5×10-11 m2s-1. The time to move 1 meter would be about, or about 28 hours. Thus, we need a circulatory system.

In the main text I reprised the calculation of 370,000 years for a photon moving at the speed of light between collisions to make it from the Sun’s core to the surface. Stars of our Sun’s size have circulation only at the edges. Bigger, hotter stars have large convective zones.