/* BACKMET.C: A computer program for running the "backmet" web browsing algorithm developed in the paper "Achieving Limiting Distributions for Markov Chains Using Back Buttons", by A. Feuerverger and J.S. Rosenthal, available from http://probability.ca/jeff/research.html Copyright (c) 2003 by Jeffrey S. Rosenthal. Licensed for general copying, distribution and modification according to the GNU General Public License (http://www.gnu.org/copyleft/gpl.html). */ #include #include #include #include #include #define N 1000 /* Number of states. */ #define K 6 /* Number of extra links per state. */ #define C 10 /* To make target distribution pi[i] = i+C. */ #define TSERIESLENGTH 20 #define RUNLENGTH 40 /* number of k-blocks to run each time */ #define NUMREPS 100000000 #define PRINTLENGTH 10000 #define MAXOUTLINKS 30 int outlinks[N]; int linkplace[N][MAXOUTLINKS]; double qf[N][100]; double t[N]; int allpos = 0; int i,j,h,r; main() { double pi[N]; double sum; int k; int timespent[N][RUNLENGTH]; int state, proposal; double tv; double absval(); seedrnd(); /* Initialise outlinks[i]. */ for (i=0; i= MAXOUTLINKS) || (outlinks[jj] >= MAXOUTLINKS) ) { fprintf(stderr, "Too many outlinks from link %d or %d.\n", ii, jj); exit(1); } linkplace[ii][outlinks[ii]] = jj; #ifdef VERBOSE printf("ii=%d, jj=%d, outlinks[ii]=%d, outlinks[jj]=%d ... ", ii,jj,outlinks[ii],outlinks[jj]); printf("linkplace[%d][%d] = %d\n", ii, outlinks[ii], jj); #endif linkplace[jj][outlinks[jj]] = ii; outlinks[ii]++; outlinks[jj]++; } double absval(double x) { if (x<0) return(-x); return(x); }