Applied Physics 461b/861b

COMPUTATIONAL PHYSICS

Assignment 8

due Friday, April 11, 1997

Reading

  1. Gould and Tobochnik Chapter 7.3, 7A, 12.1-12.3, 12.6.
  2. Numerical Recipes, Sections 7.0-7.1.

1. Getting a feel for random numbers

(a) Write a short program which calls one of the Numerical Recipes random number generators (e.g. the recommended ran1) to generate a sequence of N random numbers uniformly distributed between 0 and 1. Examine the distribution of the sequence you generated by producing a histogram. The bins should be small enough so that each contains a `large' number of values. Make a plot to display your results visually.

(b) Investigate how the deviation from the limiting distribution decreases as N increases. Comment.

Note: you can read about/try out additional tests of randomness described in Problem 12.19.

Note on histograms in pgplot: You can display your histogram by inserting the following code, where NINT is the number of bins you have used, XVAL is the array containing the x coordinate of the lower edge of each bin, and OCC is the occupancy (normalized) of each bin.

LOGICAL CENTER
...
CALL PGBEGIN(0,'/PS',1,1)
CALL PGENV(0.0,1.0,0.0,1.1,0,1)
CENTER=FALSE
CALL PGBIN(NINT,XVAL,OCC,CENTER)
CALL PGEND

Alternatively, pgplot will actually make the histogram plot for you, but you have to save the values of x in an array (which can get quite large). Insert the following code, where NTR is the number of values of x, XSAVE is the array containing these values, and NINT is the number of bins you want in the histogram.

CALL PGBEGIN(0,'/PS',1,1)
CALL PGHIST(NTR,XSAVE,0.00,1.00,NINT,0)
CALL PGEND

2. Introduction to random walks

Do Problem 7.6 a, b ( program random_walk).

3. Restricted random walks in one dimension

Do Problem 12.5 a, b.

4. The two-dimensional self-avoiding walk

Do Problem 12.12 (note that the simple two-dimensional random walk is discussed in Problem 12.2, with program program random_walk2).