/*------------------------------------------------------------- Copyright (C) 2000 Peter Clote. All Rights Reserved. Permission to use, copy, modify, and distribute this software and its documentation for NON-COMMERCIAL purposes and without fee is hereby granted provided that this copyright notice appears in all copies. THE AUTHOR AND PUBLISHER MAKE NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHORS AND PUBLISHER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. -------------------------------------------------------------*/ /*--------------------------------- randomWalkDistance.c Computes mean and variance between corresponding points between 2 random walks. Used for algorithms problem. Generates data on average distance between points of 2 random walks on 2 dimensional lattice. Program rather similar to randomWalk.c, except: compute mean distance instead of (root) mean square distance read in length of walks --------------------------------*/ #include #include #include double rreal(); int randint(int); main(int argc, char *argv[]) { int i,j; int M = 100000; // number of runs int n; // n points in walk int x,y,u,v; double distSum; // sum of distances between successive points on walk double sum=0,sumSq=0; // used to compute mean and variance of distances between walks /*--------error handling for input */ if (argc != 2) { fprintf(stderr,"%s int\n",argv[0]); exit(1); } n = atoi(argv[1]); for (i=0;i