#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { double p, q; int N; int * x, *y, *z; int i; int t, T, TRANS; double tau[2][2]; double m, summ; srand48(time(NULL)); N = 100; T = 100; TRANS=10000; x = calloc(N+1, sizeof(int)); y = calloc(N+1, sizeof(int)); for (q=0; q<=1; q+= 0.05) { for (p=0; p<=1; p+= 0.05) { tau[0][0]=0; tau[0][1]=tau[1][0] = p; tau[1][1]= q; summ=0; for (i=0; i<N; i++) { x[i] = drand48() < 0.5? 1 : 0; } for (t=0; t<T+TRANS; t++) { x[N] = x[0]; // boundary conditions for (i=0; i<N; i++) { y[i] = drand48() < tau[x[i]][x[i+1]] ? 1 : 0; } z = x; x = y; y = z; m = 0; for (i=0; i<N; i++) { m += x[i]; } if (t>TRANS) { summ += m/N; } } printf("%f %f %f\n", p, q, summ/T); } } }