Monday, December 7, 2020

Mean points

 We can also look for a mean set of points. This has continuous rather than discrete symmetries. The starting point is the 1D case: what is the mean set of repeating point locations? It depends on how many points are in the sequence, so here is the answer for the first 10 numbers of points:

The images on the left represent the sequence as the points in a circle (rendered as radial spokes). 

As you can see, the result is fairly trivial, the sequence seems to be symmetric, with a single largest gap, and progressively smaller gaps on either side of it. 

If we include reflection of the sequence in the equivalence class, the results appear to be exactly the same.

2D

We could explore the 2D case in a toroidal universe as with the previous mean textures post, but this doesn't easily allow a continuous rotational symmetry. Instead, let's look at a spherical universe, so find the mean set of n random points on a sphere. 

To do this, I need a way to find the least squares orientation between two sets of points on a sphere. To avoid the uncertainties of approximate methods (such as Iterative Closest Point etc) I compare all permutations of the points and run an absolute orientation function on each permutation (Eigen::umeyama). The R which has the smallest sum of squares difference is chosen, and applied to one set of points before averaging them and renormalising.

Unfortunately, this permutations approach is intractable for larger numbers of points, so I show here only up to 5 points. Giving just a hint of the pattern for mean points on a sphere.

2 points:  (right angle)

0.437025 0.490747 0.753775,   0.67137 0.379744 -0.63644

3 points: 

 
0.147701 -0.525988 -0.837568,   0.981211 -0.192266   0.01611,   0.104602 -0.529166  0.842047

4 points:

-0.394284 -0.910857 -0.121984,  -0.680957  0.712358 -0.169835,   -0.983752 -0.0842168   0.158555,   0.184711  0.622359 -0.760626

5 points:

-0.295731  0.738672 -0.605728,   0.690733 0.0875932 -0.717785,   -0.97845 0.0669067 -0.195341,  -0.301121 -0.657821 -0.690361,  -0.651082 -0.174766  0.738613

6 points:

0.129365 -0.627223  0.768021,  -0.434599 -0.871754 -0.226204,   0.367076 -0.768696 -0.523795,  -0.841728 -0.113547  0.527827,   0.769293  0.153797 -0.620109,  -0.778213   0.13924  -0.61237
 


These at least show that the mean set of points on a sphere does not follow a trivial pattern. The points aren't in a plane or even within a radial cone.


Wednesday, December 2, 2020

Mean textures

We can extend the idea of mean signals into 2D, as mean textures. In the previous post I found two signed and two complex signals that were non-trivial (they didn't tend to a spike signal). Here I look at the case for 2D, on signed textures (greyscale with 127=0). 

Here are the results with no 90 degree rotational symmetry. Showing a 5x5 tiled patch from a 2x2 texture (left) up to a 5x5 texture (right):

If I include reflection when matching:


If I include 90 degree rotational symmetry (no reflection):

And with reflection included:

Finally, for comparison, here is an unsigned texture, with 90 degree rotational symmetry, no reflection:


The unsigned texture is just like the unsigned signal of the previous post. The mean is a single spike. For the signed textures, they all appear to tend towards a pair of extremes (one positive, one negative) as the width goes up to 5.

One reasonable variant is for the random values to be a uniform distribution of signal energies (value squared). This supports the need for negative values, since we are taking the square root of the uniformly sampled numbers.

Here is with no reflection: (28 iterations)

and with reflection (28 iterations):

These do not show the same tendency towards a trivial case of one or two spikes at larger resolutions. However, the accuracy of the 5x5 is very poor, due to the huge number of iterations needed to converge. The rest are quite close, as verified by trialing with different random seeds.

Here's the above 4x4 (no reflection) shown over a larger surface:

We also do something very similar in the complex domain. Here I use the red component for real values, the green for imaginary values and set the blue to halfway. Lower iteration count (23) just to give an indication of what it might look like:

without reflection:

with reflection: 


Mean signals

Here I look at the average of discrete repeating signals. That is, I pick random signals (by sorting a random set of values between 0 and the signal length, and using the differences). Then I match the signal to the running average using a cross-correlation, by sliding in time, and optionally reversing the signal direction.

Here are the sequences visualised, from length 1 to 10. One grid cell is 2 units high.


no reflection                                        reflection

We can also include negative numbers. Each candidate sequence has a sum of absolute values equal to the sequence length. A cross-correlation works equally well, but we can also choose whether to allow negation of the values when matching. Here grid cells are 8 units.

1,3: no reflection, 2,4: reflection. 3,4 includes negation when matching.

A different approach is to pick random values between 0 and 1, and match based on minimising sum of square error, rather than maximising cross correlation:

left side: unsigned, right side signed. 1,3 no reflection, 2,4 allows reflection

Notice that the results get smaller for larger sequences. This isn't true for the cross-correlation, and I find the cross-correlation method more general as it represents scale-independent matching.


A natural extension of the cross-correlation on signed numbers is to use complex numbers. We cross correlate as the sum of one times the conjugate of the other, and pick the match with the largest real component.

 
left: no reflection                                    right: with reflection of signal index

There are more reflection options for complex numbers. We could also negate the value in the reflected match (below left), or conjugate the complex value in the reflected match (below right): 

 

Of the four, it looks like the first two (no-reflect and reflect) give the least trivial result.

We can also use the largest absolute value in the cross-correlation, and so 'rotate' the complex signal when adding it on. This is adding an explicit phase invariance. However, these give more trivial results:

left: no reflection, middle: reflection included, right: reflection with conjugation.

It is not clear that having an even distribution of absolute values is the best constraint on signed and complex values. It may make sense to have an even distribution of signal energy (value squared). Doing so gives results with slightly less spiking and clearer patterns:


left: no reflection, right: reflection allowed.

I have only shown signal lengths 1 up to 8, as the larger ones become too inaccurate, but the above are repeatable. The no-reflection case, shows a hint of a pattern, with the n=2, 4 and 8 cases close to square waves. and the n=3 and 6 cases being uneven square waves. As for the reflection case, it shows signs of following a saw-tooth wave until about n=6.