// Walk.java Random walk simulation import java.io.*; // Location of PrintWriter import java.util.*; // Location of Random import java.lang.*; // Location of Math public class Walk { public static void main(String[] argv) throws IOException, FileNotFoundException { PrintWriter q = new PrintWriter( new FileOutputStream("Walk.dat"), true); int imax = 1999, jmax = 10000, i = 0, j = 0; double x = 0., y = 0., root2 = Math.sqrt(2.), r[] = new double[imax + 1]; long seed = 3008157; // New seeds => new sequence Random randnum = new Random(seed); // To access next: randnum.nextDouble() for ( i=0; i <= imax; i++ ) r[i] = 0. ; // Initialize r for ( j=0; j <= jmax; j++ ) { // Average over trials x = 0. ; y = 0. ; // Start at origin for ( i=0; i <= imax; i++ ) { // -root2