Re: Iterated Function System
- To: mathgroup at smc.vnet.net
- Subject: [mg67704] Re: Iterated Function System
- From: "Julian Aguirre" <julian.aguirre at ehu.es>
- Date: Wed, 5 Jul 2006 04:17:55 -0400 (EDT)
- References: <e8d0uo$4dk$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
James, > I am looking for a faster way to plot Iterated Function Systems in Mathematica. Currently my method is using Barnsley's algorithm which randomly chooses a transformation and applies it to a previous point to get the next point. I then store the points in a list corresponding to the transformation that was applied to it. Is there a faster way to program this using functional programming in Mathematica? Thanks in advance. > This problem has been treated in The Mathematica Journal 7(1): 6-13 (1997). This is my code, based on the ideas in that article. delta=.06; (* small number *) maxiter=20000; (* number of points *) (* The IFS *) fern={ {{{0.81,0.07},{-0.04,0.84}},{0.12,0.195}}, {{{0.18,-0.25},{0.27,0.23}},{0.12,0.\ 02}},{{{0.19,0.275},{0.238,-0.14}},{0.16,0.12}}, {{{0.0235,0.087},{0.045,0.1666}},{0.11,0.0}} }; l=Range@Length@fern; fixedpoints=Inverse[IdentityMatrix[2]-#[[1]]].#[[2]]&/@fern; p0=Last@puntosfijos; (* Starting point *) probs=(#/Plus@@#)&@Map[Max[delta, Abs@Det[#[[1]]]]&, fern] (* probabilities *) cum=FoldList[Plus,.0,probs]; alstd:=With[{r=Random[]}, First@Select[l,(cum[[#]] < r = cum[[#+1]]) &] ]; (* gives integer i with probability prob[[i]] *) f[x_]:=With[{g=fern[[alstd]]}, g[[1]].x+g[[2]]]; (* One step inthe iteration *) ListPlot[NestList[f,p0,maxiter], AspectRatio->Automatic, PlotStyle->{AbsolutePointSize[1],Green}, Axes->None]; Julian Aguirre Universidad del Pais Vasco > James Rohal > College of Wooster 2007