#!/usr/local/bin/perl -w # # pepper.p writes an image which I claim lempel ziv would not be good # at compressing # # this does not work under perl 5 # # pepperb.p uses a spatially varying flipping rate # $pbmplot = 1 ; $pbmfile = "figs/wallpaperb.pbm" ; $pbmx = 400 ; # $screen = 0 ; $bias = 0.4 ; # initial fraction that are 1 $beta = 2 ; # skewness of distbn . $pbmy = 100 ; # eval "\$$1=\$2" while $ARGV[0]=~ /^(\w+)=(.*)/ && shift; # $l=1 ; $r = $pbmx ; $T = $pbmy ; if ( $pbmplot ) { # note I actually write a pgm file . open (PBM,"> $pbmfile"); if ( $T < $pbmy ) {$pbmy = $T ; } print PBM "P1\n# CREATOR: pepper.p DJCM 97 02 15\n" ; print PBM "$pbmx $pbmy\n" ; # print PBM "$maxpbm\n" ; } # initial state for ( $i = $l ; $i <= $r ; $i ++ ) { $c[$i] = ( rand() > $bias ) ? 0 : 1 ; } # flipping rates for ( $i = $l ; $i <= $r ; $i ++ ) { $fa = rand(); $la = log($fa/(1-$fa)); $flip[$i] = 1.0/(1.0+exp(-$beta * $la)); } for ( $t = 1 ; $t <= $T ; $t ++ ) { for ( $i = $l ; $i <= $r ; $i ++ ) { print PBM "$c[$i] " ; if ( rand() < $flip[$i] ) { $c[$i] = 1 - $c[$i] ; } } print PBM "\n" ; } if ( $pbmplot ) { # bottom line close ( PBM ) ; } print STDERR "\n# xv $pbmfile\n" ;