MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: [?? Probable Spam] converting function from RasterArray to Raster

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81756] Re: [?? Probable Spam] [mg81690] converting function from RasterArray to Raster
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Wed, 3 Oct 2007 02:23:43 -0400 (EDT)
  • References: <27780983.1191341961719.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

The call

results = randomWalkers[100, 0.65, 1, 1, 1, 1, 10000];

doesn't match the pattern

randomWalkers[n_, p_, g_, m_, s_, r_, t _]

Bobby

On Tue, 02 Oct 2007 04:21:38 -0500, Ricardo Pietrobon <pietr007 at gmail.com>  
wrote:

> Hi,
>
> I am new to mathematica and trying to convert a call to RasterArray to
> Raster in Mathematica 6.0.  The old function, which used to work with
> RasterArray was:
>
> m = Max[First[results]];
> Show[GraphicsRow[(Graphics[
>       RasterArray[Map[
>         If[#1 === 0, GrayLevel[1], GrayLevel[#1[[2]]/m]] &, #1, {2}]],
>        AspectRatio -> Automatic] &) /@ {First[results],
>     Last[results]}]]
>
>
> Simply substituting RasterArray by Raster won't do the trick, but the
> debugger doesn't catch a syntatic problem.  Any thoughts on how to get
> the function to work with Raster would be appreciated.
>
> Ricardo
> Duke University
> PS - By the way, the full code (which actually came from the
> Simulating Society book by Gaylord) is below:
>
>
> randomWalkers[n_, p_, g_, m_, s_, r_, t _] :=
>   Module[{society, RND, k, walk, GN}, RND := RandomInteger[{1, 4}];
>    k = 0; society =
>     Table[Floor[p + RandomReal[]], {n}, {n}] /.1 :> {RND, ++k,
>        Floor[g + RandomReal[]], RandomInteger[{1, m}, s],
>        RandomInteger[{0, r}]};
>    walk[{l, a___}, 0, _, _, _, {4, ___}, _, _, _, _, _, _, _] := {RND,
>       a}; walk[{l, a___},
>      0, _, _, _, _, _, _, {2, ___}, _, _, _, _] := {RND, a};
>    walk[{l, a___}, 0, _, _, _, _, _, _, _, {3, ___}, _, _, _] := {RND,
>       a}; walk[{l, a___}, 0, _, _, _, _, _, _, _, _, _, _, _] := 0;
>    walk[{2, a___}, _, 0, _, _, {3, ___}, _, _, _, _, _, _, _] := {RND,
>       a}; walk[{2, a___}, _,
>      0, _, _, _, {1 ___}, _, _, _, _, _, _] := {RND, a};
>    walk[{2, a___}, _, 0, _, _, _, _, _, _, _, {4, ___}, _, _] := {RND,
>       a}; walk[{2, a___}, _, 0, _, _, _, _, _, _, _, _, _, _] := 0;
>    walk[{3, a___}, _, _, 0, _, _, {4, ___}, _, _, _, _, _, _] := {RND,
>       a}; walk[{3, a___}, _, _,
>      0, _, _, _, {2, ___}, _, _, _, _, _] := {RND, a};
>    walk[{3, a___}, _, _, 0, _, _, _, _, _, _, _, {1, ___}, _] := {RND,
>       a}; walk[{3, a___}, _, _, 0, _, _, _, _, _, _, _, _, _] := 0;
>    walk[{4, a___}, _, _, _, 0, _, _, {1, ___}, _, _, _, _, _] := {RND,
>       a}; walk[{4, a___}, _, _, _,
>      0, _, _, _, {3, ___}, _, _, _, _] := {RND, a};
>    walk[{4, a___}, _, _, _, 0, _, _, _, _, _, _, _, {2, ___}] := {RND,
>       a}; walk[{4, a___}, _, _, _, 0, _, _, _, _, _, _, _, _] := 0;
>    walk[{_, a___}, _, _, _, _, _, _, _, _, _, _, _, _] := {RND, a};
>    walk[0, {3, ___}, {4, ___}, _, _, _, _, _, _, _, _, _, _] := 0;
>    walk[0, {3, ___}, _, {1, ___}, _, _, _, _, _, _, _, _, _] := 0;
>    walk[0, {3, ___}, _, _, {2, ___}, _, _, _, _, _, _, _, _] := 0;
>    walk[0, _, {4, ___}, {1, ___}, _, _, _, _, _, _, _, _, _] := 0;
>    walk[0, _, {4, ___}, _, {2, ___}, _, _, _, _, _, _, _, _] := 0;
>    walk[0, _, _, {1, ___}, {2, ___}, _, _, _, _, _, _, _, _] := 0;
>    walk[0, {3, a___}, _, _, _, _, _, _, _, _, _, _, _] := {RND, a};
>    walk[0, _, {4, a___}, _, _, _, _, _, _, _, _, _, _] := {RND, a};
>    walk[0, _, _, {1, a___}, _, _, _, _, _, _, _, _, _] := {RND, a};
>    walk[0, _, _, _. {2, a___}, _, _, _, _, _, _, _, _] := {RND, a};
>    walk[0, _, _, _, _, _, _, _, _, _, _, _, _] := 0;
>    GN[func_, lat_] :=
>     MapThread[
>      func, (RotateRight[lat, #1] &) /@ {{0, 0}, {1, 0}, {0, -1}, {-1,
>         0}, {0, 1}, {1, -1}, {-1, -1}, {-1, 1}, {1, 1}, {2,
>         0}, {0, -2}, {-2, 0}, {0, 2}}, 2];
>    NestList[GN[walk, #1] &, society, t]];
>
> SeedRandom[2];
> results = randomWalkers[100, 0.65, 1, 1, 1, 1, 10000];
>
>



-- 

DrMajorBob at bigfoot.com


  • Prev by Date: Re: Re: Modifying the Default stylesheet?
  • Next by Date: Re: Strange Laplace Transform in 6.0
  • Previous by thread: Mathematica Special Interest Group (Northern VA and Washington DC)
  • Next by thread: BarChart - intensity of colour increases up the bar