Randomness Followup

Starting with four vertices.

In yesterday’s post a fractal was made by repeatedly moving a point halfway to a randomly selected vertex of a triangle, and I noted that the same magic does not happen with four vertices.  How young and foolish I was then!

Playing with the code a bit, I found that you may instead

2. Choose a random vertex v.

3. Move your point to the point (x+(n-2)v)/(n-1)).

4. Repeat.

Notice that if n was 3, we get the recipe for the Sierpinski triangle (aka carpet, aka gasket) from yesterday.  Also, if n is 2, then you get a single point (which, ok, is a fractal in that it is self similar, but sort of sucks).  I haven’t checked, but it looks like the Hausdorff dimension of the fractal produced starting with n vertices is something like ln(n)/ln(n-1).  More on calculating that later.

Anyways, here is the MATLAB code for creating these fractals, and pictures of a few of them.

``` function gasketn(rad,n,d,sides) %creates a fractal with radius rad, n points, each point of size d, and %"sides" sides. gasketn(1,100000,1,3) creates a Sierpinski gasket. t = linspace(0,2*pi,sides+1); x = [rad*cos(t),rad]; y = [rad*sin(t),0]; point = zeros(n,2); vert = randi(sides,n,1);```

```for j = 2:n point(j,:) = point(j-1,:)/(sides-1) + (sides-2)*[x(vert(j)),y(vert(j))]/(sides-1); end scatter(point(:,1),point(:,2),d,'k','filled') axis off end ```

Starting with five vertices.

Six vertices!

Twelve vertices! And now this is getting silly...