Tuesday, 17 March 2015

spike fourier transform using simm

This post just a quick one. We can use similar[op] to do an approximation to a Fourier Transform.

Here is the BKO:
```spikes |wave-1> => range(|0>,|1000>,|1>)
spikes |wave-2> => range(|0>,|1000>,|2>)
spikes |wave-3> => range(|0>,|1000>,|3>)
spikes |wave-4> => range(|0>,|1000>,|4>)
spikes |wave-5> => range(|0>,|1000>,|5>)
spikes |wave-6> => range(|0>,|1000>,|6>)
spikes |wave-7> => range(|0>,|1000>,|7>)
spikes |wave-8> => range(|0>,|1000>,|8>)
spikes |wave-9> => range(|0>,|1000>,|9>)
spikes |wave-10> => range(|0>,|1000>,|10>)
spikes |wave-11> => range(|0>,|1000>,|11>)
spikes |wave-12> => range(|0>,|1000>,|12>)
spikes |wave-13> => range(|0>,|1000>,|13>)
spikes |wave-14> => range(|0>,|1000>,|14>)
spikes |wave-15> => range(|0>,|1000>,|15>)
```
Now, load that into the console:
```sa: load make-ft-spikes.sw
sa: simm |*> #=> 100 self-similar[spikes] |_self>
sa: map[simm,similarity] rel-kets[spikes] |>

sa: matrix[similarity]
[ wave-1  ] = [  100.0  50.05  33.37  25.07  20.08  16.68  14.29  12.59  11.19  10.09  9.09   8.39   7.69   7.19   6.69   ] [ wave-1  ]
[ wave-2  ]   [  50.05  100.0  33.33  50.1   20.16  33.33  14.37  25.15  11.18  20.16  9.18   16.77  7.78   14.37  6.79   ] [ wave-2  ]
[ wave-3  ]   [  33.37  33.33  100.0  25.15  20.06  50.0   14.37  12.57  33.53  10.18  9.28   25.15  7.78   7.19   20.06  ] [ wave-3  ]
[ wave-4  ]   [  25.07  50.1   25.15  100.0  20.32  33.47  14.34  50.2   11.16  20.32  9.16   33.47  7.97   14.34  6.77   ] [ wave-4  ]
[ wave-5  ]   [  20.08  20.16  20.06  20.32  100.0  16.92  14.43  12.94  11.44  50.25  9.45   8.46   7.96   7.46   33.33  ] [ wave-5  ]
[ wave-6  ]   [  16.68  33.33  50.0   33.47  16.92  100.0  14.37  25.15  33.53  20.36  9.58   50.3   7.78   14.37  20.36  ] [ wave-6  ]
[ wave-7  ]   [  14.29  14.37  14.37  14.34  14.43  14.37  100.0  12.59  11.19  10.49  9.09   8.39   7.69   50.35  6.99   ] [ wave-7  ]
[ wave-8  ]   [  12.59  25.15  12.57  50.2   12.94  25.15  12.59  100.0  11.11  20.63  9.52   33.33  7.94   14.29  7.14   ] [ wave-8  ]
[ wave-9  ]   [  11.19  11.18  33.53  11.16  11.44  33.53  11.19  11.11  100.0  10.71  9.82   25.0   8.04   7.14   20.54  ] [ wave-9  ]
[ wave-10 ]   [  10.09  20.16  10.18  20.32  50.25  20.36  10.49  20.63  10.71  100.0  9.9    16.83  7.92   14.85  33.66  ] [ wave-10 ]
[ wave-11 ]   [  9.09   9.18   9.28   9.16   9.45   9.58   9.09   9.52   9.82   9.9    100.0  8.79   7.69   7.69   7.69   ] [ wave-11 ]
[ wave-12 ]   [  8.39   16.77  25.15  33.47  8.46   50.3   8.39   33.33  25.0   16.83  8.79   100.0  8.33   14.29  20.24  ] [ wave-12 ]
[ wave-13 ]   [  7.69   7.78   7.78   7.97   7.96   7.78   7.69   7.94   8.04   7.92   7.69   8.33   100.0  7.79   7.79   ] [ wave-13 ]
[ wave-14 ]   [  7.19   14.37  7.19   14.34  7.46   14.37  50.35  14.29  7.14   14.85  7.69   14.29  7.79   100.0  6.94   ] [ wave-14 ]
[ wave-15 ]   [  6.69   6.79   20.06  6.77   33.33  20.36  6.99   7.14   20.54  33.66  7.69   20.24  7.79   6.94   100.0  ] [ wave-15 ]
```
I guess that is it. I leave it up to the audience to interpret the matrix results. I guess the main point is that if a wave has frequency f, then it is somewhat similar to a wave with frequency k*f for k an integer, and by "wave" I mean a very spiky wave.

Actually, we can visualize this with a couple of examples:
```sa: table[wave,coeff] coeff-sort similarity |wave-2>
+---------+--------+
| wave    | coeff  |
+---------+--------+
| wave-2  | 100.0  |
| wave-4  | 50.1   |
| wave-1  | 50.05  |
| wave-3  | 33.333 |
| wave-6  | 33.333 |
| wave-8  | 25.15  |
| wave-5  | 20.16  |
| wave-10 | 20.16  |
| wave-12 | 16.766 |
| wave-7  | 14.371 |
| wave-14 | 14.371 |
| wave-9  | 11.178 |
| wave-11 | 9.182  |
| wave-13 | 7.784  |
| wave-15 | 6.786  |
+---------+--------+

sa: table[wave,coeff] coeff-sort similarity |wave-3>
+---------+--------+
| wave    | coeff  |
+---------+--------+
| wave-3  | 100.0  |
| wave-6  | 50.0   |
| wave-9  | 33.533 |
| wave-1  | 33.367 |
| wave-2  | 33.333 |
| wave-4  | 25.15  |
| wave-12 | 25.15  |
| wave-5  | 20.06  |
| wave-15 | 20.06  |
| wave-7  | 14.371 |
| wave-8  | 12.575 |
| wave-10 | 10.18  |
| wave-11 | 9.281  |
| wave-13 | 7.784  |
| wave-14 | 7.186  |
+---------+--------+

sa: table[wave,coeff] coeff-sort similarity |wave-4>
+---------+--------+
| wave    | coeff  |
+---------+--------+
| wave-4  | 100.0  |
| wave-8  | 50.199 |
| wave-2  | 50.1   |
| wave-6  | 33.466 |
| wave-12 | 33.466 |
| wave-3  | 25.15  |
| wave-1  | 25.075 |
| wave-5  | 20.319 |
| wave-10 | 20.319 |
| wave-7  | 14.343 |
| wave-14 | 14.343 |
| wave-9  | 11.155 |
| wave-11 | 9.163  |
| wave-13 | 7.968  |
| wave-15 | 6.773  |
+---------+--------+

sa: table[wave,coeff] coeff-sort similarity |wave-5>
+---------+--------+
| wave    | coeff  |
+---------+--------+
| wave-5  | 100.0  |
| wave-10 | 50.249 |
| wave-15 | 33.333 |
| wave-4  | 20.319 |
| wave-2  | 20.16  |
| wave-1  | 20.08  |
| wave-3  | 20.06  |
| wave-6  | 16.915 |
| wave-7  | 14.428 |
| wave-8  | 12.935 |
| wave-9  | 11.443 |
| wave-11 | 9.453  |
| wave-12 | 8.458  |
| wave-13 | 7.96   |
| wave-14 | 7.463  |
+---------+--------+
```
I guess that should make the results a little clearer.

Update: I wonder if the brain makes use of something like this?

Update: likewise, we should be able to use simm to measure distances.