From Random Numbers to Monte Carlo Random Numbers, Random Walks, Diffusion, Monte Carlo integration, and all that
Random Walk Through Life Random Walk Through Life If you flip the coin 5 times you will probably be about five steps away from where you started. This is because five times five equals 5. A random walk is not a very fast way to get anywhere! When you try this, you will notice that sometimes you go much farther than you expect and sometimes you end up very close to where you started. But if you repeat it many times or get several of your friends to do it with you with coins of their own, the average distance should come out as expected. In science we can often predict what will happen on the average even when the process is random.
Random Walk: From Physics to Wall Street A random process consisting of a sequence of discrete steps of fixed length: vary greatly depending on the dimension in which the walk occurs and whether it is confined to a lattice. The random thermal perturbations in a liquid are responsible for a random walk phenomenon known as Brownian motion. The collisions of molecules in a gas are a random walk responsible for diffusion.
For over half a century financial experts have regarded the movements of markets as a random walk - unpredictable meanderings akin to a drunkard's unsteady gait - and this hypothesis has become a cornerstone of modern financial economics and many investment strategies: markets were "weakform efficient", implying that past prices could not be used to forecast future prices changes. Lo and MacKinlay find that markets are not completely random after all, and that predictable components do exist in recent stock and bond returns.
Einstein (1905): Kinetic Theory of Brownian Motion Brownian motion -> The random walk motion of small particles suspended in a fluid due to bombardment by molecules obeying a Maxwellian velocity distribution (J. Ingenhousz 1785; Brown 188). Brownian trajectories are continuous, but of infinite length between any two points. dv m = αv + F t α = πηa m xx x xx xf t dt ɺ ɺ = α ɺ + d d m ( xxɺ ) = m xxɺ = m xɺ α xxɺ + xf( t) d dt ( ), 6 ( ) ( ) 1 1 kt 1 γt α xf( t) = x F( t) = 0, xɺ = kt, x = t (1 e ), γ α = γ m 1 kt t 1 ktt t γ x =, t γ x = m 3πη a kt t πη a r = 3 x r = = D t
Monte Carlo Methods: Not one, but many Any method that solves a problem by generating suitable random numbers and observing that fraction of the numbers obeying some property or properties. The method is useful for obtaining numerical solutions to problems which are too complicated to solve analytically. It was named by S. Ulam, who in 1946 became the first mathematician to dignify this approach with a name, in honor of a relative having a propensity to gamble. Nicholas Metropolis: Metropolis algorithm in Statistical Physics among the top 10 algorithms having the "greatest influence on the development and practice of science and engineering in the 0th century."
Random Numbers in Computers? Uniform distribution of pseudo-random numbers x ( ax b) mod m n+ 1 = n + can be generated by this linear congruential generator. Here a, b and m are carefully chosen fixed integers, a is the multiplier, b is the increment and m is the modulus. The starting value x 0 is called the seed. The random number in the interval [0, 1] is x / m n. Hence there are at most m random uniformly distributed numbers: P ( x ) = 1 if x [0,1] P ( x ) = 0 if x [0,1]
Is the distribution really uniform? Knut s ran3.c or ran3.for portable generator (it does not employ linear congruential method!):
Non-uniform distributions Transformation method: y = f ( x) dx Px ( x) dx = Py ( y) dy Py ( y) = Px ( x) = C dy y 1 ( ) ( ) ( ) ( ) x = F y = P y dy y x = F x 0 dx dy
Example: Exponential Deviates Transformation method: y = ln( x) P ( y) = e y, 0 y y
Non-uniform Distributions: Transformation Method Transformation method does not always work: 1 y Py ( y) = exp π y dx 1 y 1 t = exp x = exp dt dy π π y( x) No analytical expression for in the case of Normal Distribution!
Non-uniform Distributions: Rejection Method Suppose we have a comparison function f ( x) with the properties: P( x) < f ( x) x, f ( x) dx < Now suppose we can choose a random point in two dimensions that is uniformly distributed in the area under the comparison function f ( x). If the point lies outside the area under P( x) then reject it and choose again. Otherwise, accept the point. The accepted points are uniformly distributed in the accepted area.
Rejection Method Summarized
x 0 Rejection Method in Practice Choose a comparison function whose indefinite integral is known analytically and is analytically invertible, i.e., you can find x such that : f ( x ') dx ' = z Let A be the total area under f(x). Pick a uniform random number 0 < α < A. Then find x so that: x 0 f ( x ') dx ' = α Now pick a random number y between 0 and f(x). Accept x if y<p(x), reject otherwise.
P x x x x Rejection Method: Example ( ) = 30 (1 ), 0 1 40 1 x, 0 x 9 f ( x) = 40 1 (1 x), x 1 9
Monte Carlo Integration The most common application of the Monte Carlo method is Monte Carlo integration (extension of the rejection method). b a Y NIN f ( x) dx ( b a) Y N [ a, b] TRIALS > max f ( x) In order to integrate a function over a complicated domain D, Monte Carlo integration picks random points over some simple domain D which is a superset of D, checks whether each point is within D, and estimates the area of D (volume, n-dimensional content, etc.) as the area of D multiplied by the fraction of points falling within D.
Ultra Classic Example: A circle A standard example is to use the Monte Carlo method to find the area of a circle and hence determine a value for. π b a N b a f ( x) dx f ( xi ) N 1 1 1 1 i= 1 N 4 π = p( x, y) dxdy p( xi, yi ) N p( x, y) + = 0, otherwise 1, x y 1 i= 1
Monte Carlo Integration: Error Estimate Suppose we pick N random points uniformly distributed in a multidimensional volume V: x, x,, x. Then the 1 n basic theorem of Monte Carlo integration estimates the integral of a function as: f ( x) f ( x) dv f V ± V 1 1 f = f x f = f x N N N ( ), i ( i ) i = 1 N i = 1 f N f σ General Theory of Statistical Errors: 1 N trials = ( Ii I ) ( Ntrials 1) i= 1 S S I I = N σ N 1/ trials
Monte Carlo Integration: A Sphere The same basic method can be used to find the volume of a sphere: 1 / N The accuracy of this Monte Carlo method is proportional to. tria ls Hence a large number of random points is needed to get high accuracy. However, Monte Carlo integration is faster than Simpson s rule in 4 or more dimensions. It is also easy to program and is useful for evaluating and 3 dimensional integrals with complex boundaries.
Random Walk in 1D In a one-dimensional random walk, the walker can move along a straight line in either the positive direction or the negative direction. Here we will assume that steps are of unit length and that the walker can move in either direction with equal probability. x x n n = 0 t In this case the most likely distance from the starting point after n steps is 0. The plot shows the distribution of positions (both positive and negative) for 100,000 walkers after 100 steps. The distribution is normal (Gaussian) with standard deviation 10.
Random Walk in 1D Explained To see why the variance behaves this way, let during i-th step:. s = ± 1 s i be the change in position This property is characteristic of random walks and diffusion processes in any number of dimensions. i x n = n i= 1 s i n n n n n n n = i j = i j = i j i= 1 j= 1 i= 1 j= 1 i= 1 j= 1 x s s ss ss i = j s = s ss = 1 i j i j i j ss = 0 i j n n n n i j i i i= 1 j= 1 i= 1 x = ss = ss = n
From Random Walk to Diffusion To see the connection between random walks and diffusion processes, consider the probability p(m,n) that a walker is at position m after n steps. To get to position m, the walker must be at position m-1 or position m+1 at the previous step. In either case, the probability that it moves to position m is 0.5. 1 p( m, n) = [ p( m+ 1, n 1) + p( m 1, n 1) ] 1 p( m, n) p( m, n 1) = p( m+ 1, n 1) p( m, n 1) + p( m 1, n 1) [ ] p p = D t x Letting the time step and the spatial step become infinitesimally small leads to a diffusion equation.
Self-Avoiding Random Walk A self-avoiding walk is a path from one point to another which never intersects itself. Such paths are usually considered to occur on lattices, so that steps are only allowed in a discrete number of directions and of certain lengths. α α r 1.4, d = = 1.5, d = 3 1.15, d = 4 t 1 < < SAW can model coiling up of links in a polymer chain. α