Wednesday, September 20, 2023

chatGPT's Superpower is *** Self-checking ***

User
you are an expert at mathematics. generate an equation of a circle that goes through the points (0,0), (0.5,0.5), (1,0)
ChatGPT

To determine the equation of a circle that goes through the given three points, we can use the general equation of a circle:

(x - h)^2 + (y - k)^2 = r^2

Where (h, k) is the center of the circle and r is its radius.

Plugging in the given points:

  1. (0,0) gives: h^2 + k^2 = r^2 \implies r^2 - h^2 - k^2 = 0 ... (i)

  2. (0.5, 0.5) gives: (0.5 - h)^2 + (0.5 - k)^2 = r^2 \implies r^2 - h^2 + h - k^2 + k = 0.5 ... (ii)

  3. (1,0) gives: (1 - h)^2 + k^2 = r^2 \implies r^2 - h^2 + 2h - k^2 - 1 = 0 ... (iii)

Now, subtracting (i) from (ii) and (iii) gives:

h + k = 0.5 ... (iv)

2h - 1 = 0 \implies h = 0.5 ... (v)

Plugging (v) into (iv) gives: k = 0

The center of the circle is (0.5, 0).

Plugging h = 0.5 and k = 0 into (i) gives: r^2 = 0.25 \implies r = 0.5

Thus, the equation of the circle is: (x - 0.5)^2 + y^2 = 0.25

or equivalently:

(x - 0.5)^2 + y^2 = (0.5)^2

User
solve the last equation for y
ChatGPT

You want to solve the equation of the circle:

(x - 0.5)^2 + y^2 = (0.5)^2

for y.

Expanding the equation, we get:

x^2 - x + 0.25 + y^2 = 0.25

Simplifying and solving for y^2:

y^2 = 0.25 - x^2 + x

Now, taking the square root of both sides:

y = \pm \sqrt{0.25 - x^2 + x}

This will give two solutions, corresponding to the upper and lower halves of the circle.

User
are you sure about that last equation?
ChatGPT

Let's reconsider the solution:

Starting from the equation:

(x - 0.5)^2 + y^2 = (0.5)^2

x^2 - x + 0.25 + y^2 = 0.25

Subtracting 0.25 from both sides:

x^2 - x + y^2 = 0

Rearranging for y^2:

y^2 = x - x^2

Now, taking the square root of both sides:

y = \pm \sqrt{x - x^2}

This is the correct expression for y in terms of x for the circle. My apologies for the oversight in the previous response.


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=x−x2

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

Wednesday, September 6, 2023

Cellular Automata Explosion

I've written a 5-bit version of the cellular automata (CA) code.  So instead of looking at the value of the current and the 2 adjacent pixels (1 left and 1 right of the current position), I'm looking at the current and 4 adjacent pixels (2 left and 2 right).  This mean that the number of Rules for 1 layer is 2^32.

The code also allows for up to three CA layers.  The output of one layer is the input to the next:

Random Input -> Rule1 -> Rule2 -> Rule3 -> output

This is a portion of the output when Rule1 = Rule2 = Rule3 = 789263618

In binary, 789263618 = 0x01000000101011001101000011110100

So the same Rule applied three times in a row.  I get this:



That's interesting, I suppose.  I'm sure PhD dissertations can be written about it.  But for me, the fourier transform is much more interesting.  Here's the FFT of the portion shown above:



And one of the first things I think of is -- how to turn this into sound.  That'll require diving into inverse-FFTs.  Fun stuff.

In any case, maybe there are more 'interesting' CA recipes than I thought.  I'm finding them almost everywhere.

Tuesday, September 5, 2023

Cellular Automata

I've been interested in CA for many many years, and finally today I wrote my first code that implements the making of 'images' based on one (or possibly several at once) of 256 rules.

...

Well, before I knew it I've gone off the deep end with this stuff.  Making these things that show them 'evolve' is pretty cool, but it looks like there are only a few rules that make anything 'interesting'.  From out of nowhere I go the idea of combining rules.  So take the starting input, apply Rule 1, then use that as input to Rule 2, for input to Rule 3, etc.  I decided to stop at combining three Rules.  This appears to be very very very different than the rule combination on the wolfram website, where it's taking the final results of two different rules and applying xor, or, & and to the images to produce a result.  These results are boring.

The output of one Rule being the input to the next Rule is something I can't find any info on, which means I just haven't found anything yet (likely), or I've come up with something fairly novel.

Here's what combining Rules 86 and 112 look like:



The patterning here is subtle, but if I look at the power spectrum of each row I see this spectacular thing:



Here's the same thing with different starting points:



and the power spectrum:



details of the PS:




laksjdlaskjd

Sunday, September 3, 2023

More work towards 'visualizing' complex neural networks

I'm moving quicky into a realm where the only thing that really matters are histograms showing the ditribution of data for a particular sample.  And when it comes down to it, that's all a NN has, too!  At this point I think that's the direction that will lead to some form of 'visualization'.  I put that in quotes because it may or may not include information perceived through our eyes.  It may turn out, for instance, that hearing the network is the best way to understand it, or maybe some way of understanding it through color.  I have no idea, and that's why I'm doing it: because it's an interesting challenge that currently has everyone stumped.  Finding something that works could lead to who knows what?

If I don't find anything useful, I'm still forced to completely understand NNs in order to try to represent them in form that humans can have a chance at understanding.  This will make me better at designing and using NNs, which will help with my understanding, and round it goes.

Here's the sort of stuff I'm looking at.  These are histogram plots of the differences between the initial weights and the trained weights for one of the dense layers (with 128 connections) of the CNN I'm using for my object ID project.




The x-range is -1 to 1, and the y range is 0 to 2000.  I see no pattern.  The fact remains, however, that what I'm seeing here is the difference between a model that will just randomly choose an ID each time (and therefore choose incorrectly most of the time), and a model that will choose the correct ID every single time.

The fact that I don’t see anything (yet) is either an indication that I’m looking at it incorrectly (very likely), or the correct data isn’t being collected/measured/etc (also very likely).

I'll keep trying.