Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create fractals with random partial jumps toward reference points
ResourceFunction["GeneralizedChaosGame"][reg,n] plots a fractal by iteratively jumping n times toward a random point inside the reference geometry reg by jumping halfway. | |
ResourceFunction["GeneralizedChaosGame"][reg,n,jspec] uses the jumping specification jspec. | |
ResourceFunction["GeneralizedChaosGame"][reg,n,jspec,format] formats the result according to the output specification format. |
| n | n points equally spaced around the unit circle |
| {p1,p2,…} | uses the points pi as the reference geometry |
| reg | uses the region reg as the reference geometry |
| n | performs n iterations |
| Automatic | performs 104 iterations |
| α | jumps a distance α toward the next reference point |
| Scaled[α] | jumps a fraction α toward the next reference point |
| Automatic | jumps halfway toward the next reference point |
| {s1,s2,…} | cycle through the jumping specifications si |
| {"OriginIndexed", {s1,s2,…sn}} | jump using jump specification si, where i is the index of the last visited reference point |
| {“DestinationIndexed”, {s1,s2,…sn}} | jump using jump specification si, where i is the index of the next reference point |
| func | uses the function func to calculate the next position |
| "Graphics" | outputs a graphical representation of the results |
| "List" | outputs the list of coordinates visited |
| "DensityPlot" | outputs a graphical representation of the density of points |
| "PointStyle" | Automatic | style to use for the points |
| "ReferenceGeometryStyle" | Automatic | style to use for the reference geometry |
| "Probabilities" | Automatic | list of probabilities representing the chance to jump to each reference point |
| "ExclusionRegionFunction" | None | jumps that land on positions for which the function yields True are not allowed |
| "Choices" | All | restrict the possible points to jump to based on the current position or history |
| "ColorFunction" | Automatic | will use the color function ColorFunction as defined in ArrayPlot |
| "BinningSpecification" | Automatic | a list of binning specifications to use for the output format |
| "Absolute"→{b1,b2,…,bn} | restrict the jump to the reference points pi for which bi are True |
| "Relative"→{b1,b2,…,bn} | restrict the jump to the reference points pi (counted relative to the last position) for which bi are True |
| {{xmin,xmin,dx}, {ymin,ymax,dy}} | bins using the x specification and y specification |
| {dx,dy} | bins the data in bins of size dx by dy |
Create the classic Sierpiński triangle using 30,000 iterations:
| In[1]:= |
| Out[1]= | ![]() |
Jump only 40% of the way toward the reference points:
| In[2]:= |
| Out[2]= | ![]() |
Jump between 4 corners of a trapezoid:
| In[3]:= |
| Out[3]= | ![]() |
Jump between random points on a circle:
| In[4]:= |
| Out[4]= | ![]() |
Give the geometry as a list of points:
| In[5]:= |
| Out[5]= | ![]() |
The reference geometry can be any region, e.g. a Line:
| In[6]:= |
| Out[6]= | ![]() |
Perform the chaos game in higher dimensions:
| In[7]:= | ![]() |
| Out[8]= | ![]() |
Combine different regions using RegionUnion:
| In[9]:= |
| Out[9]= | ![]() |
The default jump specification is Scaled[0.5]:
| In[10]:= |
| Out[10]= | ![]() |
| In[11]:= |
| Out[11]= | ![]() |
Perform the chaos game using a 40% jump:
| In[12]:= |
| Out[12]= | ![]() |
Perform the chaos game using a jump with a distance of 0.7:
| In[13]:= |
| Out[13]= | ![]() |
Alternate between a fractional and a distance jump to create a blurry Sierpiński triangle:
| In[14]:= |
| Out[14]= | ![]() |
Alternating between a fractional and a distance jump creates a different result compared to the individual specifications:
| In[15]:= | ![]() |
| Out[15]= | ![]() |
Jump 50%, 60% or 40% if the last reference point was point 1, 2 or 3, respectively:
| In[16]:= |
| Out[16]= | ![]() |
Jump 50%, 60% or 40% if the next reference point is point 1, 2 or 3, respectively:
| In[17]:= |
| Out[17]= | ![]() |
Jump a distance of 1.75 toward the top point, and 0.5 toward all other points:
| In[18]:= |
| Out[18]= | ![]() |
Use a pure function to get a combination of fractional and distance jumping:
| In[19]:= |
| Out[19]= | ![]() |
Use more complicated functions:
| In[20]:= |
| Out[20]= | ![]() |
| In[21]:= |
| Out[21]= | ![]() |
The default is a graphical output:
| In[22]:= |
| Out[22]= | ![]() |
Obtain the results as a list and perform an operation on it:
| In[23]:= |
| Out[24]= | ![]() |
Output a density plot instead:
| In[25]:= |
| Out[25]= | ![]() |
Change the style of the points:
| In[26]:= |
| Out[26]= | ![]() |
Change the style of the reference geometry:
| In[27]:= |
| Out[27]= | ![]() |
| In[28]:= |
| Out[28]= | ![]() |
Change the probability to jump to each reference point:
| In[29]:= |
| Out[29]= | ![]() |
Restrict certain landing locations:
| In[30]:= |
| Out[30]= | ![]() |
Restrict the point to fall in a circle at the top:
| In[31]:= | ![]() |
| Out[31]= | ![]() |
Allow a jump of only 1, 3 or 4 reference points ahead as compared to the last reference point:
| In[32]:= |
| Out[32]= | ![]() |
Allow a jump only to points 2, 3 or 4:
| In[33]:= |
| Out[33]= | ![]() |
Jump possibilities can be made to depend on history. Do not allow to jump 1 ahead from the last reference point and 3 ahead from the penultimate reference point:
| In[34]:= | ![]() |
| Out[34]= | ![]() |
Have the jump choices depend on the previously visited point:
| In[35]:= | ![]() |
| Out[35]= | ![]() |
For a density plot, specify the color function used:
| In[36]:= |
| Out[36]= | ![]() |
The default is the rainbow color function:
| In[37]:= |
| Out[37]= | ![]() |
For a density plot, specify the binning specification:
| In[38]:= |
| Out[38]= | ![]() |
Or specify just the size of the bins:
| In[39]:= |
| Out[39]= | ![]() |
Explore jumping in different dimensions. Calculate the jumping in (hyper)spheres in 2D–8D, and then plot the histogram of the distance from the center:
| In[40]:= | ![]() |
| Out[40]= |
| In[41]:= | ![]() |
| Out[44]= | ![]() |
Produce the Sierpiński triangle as in a rule 90 cellular automaton:
| In[45]:= |
| Out[45]= | ![]() |
| In[46]:= |
| Out[46]= | ![]() |
The reference geometry might occlude all the points:
| In[47]:= |
| Out[47]= | ![]() |
Use the option "ReferenceGeometryStyle" to make the points visible:
| In[48]:= |
| Out[48]= | ![]() |
For a one-dimensional chaos game, explicit braces are needed:
| In[49]:= |
| Out[49]= |
| In[50]:= |
| Out[50]= | ![]() |
For each possible choice, there should be at least one True element:
| In[51]:= | ![]() |
| Out[51]= |
The "Choices" option can only be used when the region is a discrete set of points:
| In[52]:= | ![]() |
| Out[52]= |
The "Probabilities" option can only be used when the region is a discrete set of points:
| In[53]:= |
| Out[53]= |
Recreate the Barnsley fern:
| In[54]:= | ![]() |
| Out[61]= | ![]() |
Jump halfway and then jump a distance of 0.2 in the perpendicular direction:
| In[62]:= | ![]() |
| Out[62]= | ![]() |
Excluding a wolf-shaped portion of the domain results in a fractal of wolves:
| In[63]:= | ![]() |
| Out[65]= | ![]() |
Perform a halfway step and a perpendicular step of 0.1:
| In[66]:= |
| Out[66]= | ![]() |
Perform a halfway step and a scaled perpendicular step:
| In[67]:= |
| Out[67]= | ![]() |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License