Wednesday, September 20, 2023

More Cellular Automata

I now have code that will use either 3-bit or 5-bit rules.

Rules can be applied from one to three layers.  That is, Layer 1 would apply Rule 1 to the initial generation.  Layer 2 would take the output of Layer 1 and applies Rule 2 to it.  Layer 3 takes the output of Layer 2 and applies Rule 3 to it.  The output of this would be used in the next generation where each Rule would again be applied, etc.

The code is flexible enough to allow me to choose 1, 2, or 3 layers.

The code can also be set up to keep one or more Rule constant in a layer, and loop through the range of Rules in another layer for a given Rule size (3-bit --> 256 total rules, 5-bit -->  4294967296 total rules).

I run this for 2048 generations, and I make the window 2048 pixels wide (so later on my FFT is happy).  I therefore end up with 'images' that are 2048x2048 pixels in size.  I can then make some statistical measurements on these images, which means I compute the mean and standard deviation for each image produced.

For instance, in the 'simplest' case, I can apply every 3-bit rule to a starting generation that's a single pixel at location 1023 in full 2048 pixel generation.  If I do this, I'll get 256 'images' each corresponding to the application of that rule for 2048 generations.

The stats look like this:



The x-axis is the Rule number.  The y-axis is the mean value for each 'image' produced by the Rule specified.  The error bars represent the 1-sigma standard deviation.  Purple lines are 0, 0.5, and 1.  The red line indicates Rule 128.

Some observations.  A pixel can either have a value of zero or one.  So an image with a mean of zero with a small standard deviation is mostly black.  An image with a mean of one with a small standard deviation is mostly white.  An image with a mean of 0.5 and a standard deviation of +/- 0.5 would be almost completely gray (or some combination of equal white and black).

The mean and standard deviation have an interesting relationship (x-axis is the mean, y-axis is the stddev):



The 'intersting' stuff looks like to be then the mean is around 0.25 or 0.75, and the standard deviation isn't small (near zero) or high (+/- 0.5).

Here's stats on the famous Rule 30 and it's immediate neighbors.  X-axis is the Rule number, y-axis is the mean, error bars are the 1-sigma standard deviation.  Rule 30 does have an unusual characteristic in that it's the last Rule (for a little while) where the 'images' are either all black or all gray.




Here's the 'image' generated of 2048 generations of Rule 90:



Rule 92, which looks very similar statistically to Rule 90, looks very different:



So this tells me that stats like these have limited use.

My code will also move this into frequency space.  Here's the FFT of Rule 90:



I also have code that will take this data and convert it to audio.

But of course now I can apply different layers --> apply multiple rules to a single generation.  This is where things seem to get interesting.

I'll fix Rule 90 for the first layer, and then run through the 256, 3-bit rules in layer 2.  Here are the stats:



Compare it to this plot of a fixed Rule 1 in the first layer, and the the 256 rules for layer 2:


Curious and interesting...

To come to a logical conclusion, I've fixed layer 1 to be Rule 1, and layer 2 to be Rule 49, and then ran through all the Rules for layer 3.  I get these stats:




Here's the result of Rule 1 x Rule 49 x Rule 66:


and the power spectrum:


detail of a section of the power spectrum:


If I was able to post the sound to this blog, I would.  I'll put it somewhere and make a link to it.

An interesting mystery is the following:  Given the stats for a set of Rules:



If I plot mean value versus standard deviation, I get an unexpected relationship:



... seem to follow a circular relationship, of the form:

                    y2=xx2

I just checked, and the match is identical.  So this means that every standard deviation is computable given every mean value from zero to one.

Putting this into words:

stddev = sqrt (mean - mean^2)

not sure what to make of that...

Here's what I get if I keep Rule 90 static and have the next layer loop through the 256 possible Rules.  I get these results:



Gotta understand that better!

No idea where I'm going with any of this...

---

These points are the same as above, but now coded for which rule is being applied.  Zero (black) to 255 (white).

Obviously this is telling me that there is structure in the data itself.  But what, and why?  Maybe something to do with the fact that it's all 1's and 0's????  Gotta look into Binomial Distributions -- I think that's the ticket to explaining and understanding this.

A rabbit hole, for sure...

Here's yet another way to look at the data -- connecting all the dots in the path from Rule 0 to Rule 255:

Layer 1 = Rule 90, Layer 2 = Rules 0:255

Layer 1 = Rules 0:255

No comments:

Post a Comment