Thursday 29 September 2016

smoothed spike wave similarity

OK. Continuing on from the last post about spike wave similarity, let's look at smoothed spike wave similarity. This version is much more tolerant for the location of the spikes, allowing them to be in a Gaussian around the integer, rather than exactly an integer. It takes a little bit of work to reproduce this behaviour though.

Let's jump in, and start with defining our spike waves:
  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>)
  spikes |wave-16> => range(|0>,|1000>,|16>)
  spikes |wave-17> => range(|0>,|1000>,|17>)
  spikes |wave-18> => range(|0>,|1000>,|18>)
  spikes |wave-19> => range(|0>,|1000>,|19>)
  spikes |wave-20> => range(|0>,|1000>,|20>)
  spikes |empty> => 0 spikes |wave-1>
Next, we need to make use of the smooth[dx] operator. Essentially it maps:
f(x) -> f(x - dx)/4 + f(x)/2 + f(x + dx)/4
Here are a couple of examples to try and show how it works in practice:
sa: smooth[0.25] |10>
0.25|9.75> + 0.5|10.0> + 0.25|10.25>

sa: bar-chart[50] smooth[0.25] |10>
----------
9.75  : |||||||||||||||||||||||||
10.0  : ||||||||||||||||||||||||||||||||||||||||||||||||||
10.25 : |||||||||||||||||||||||||
----------
|bar chart>

sa: bar-chart[50] smooth[0.25]^5 |10>
----------
8.75  :
9.0   : |
9.25  : ||||||||
9.5   : |||||||||||||||||||||||
9.75  : |||||||||||||||||||||||||||||||||||||||||
10.0  : ||||||||||||||||||||||||||||||||||||||||||||||||||
10.25 : |||||||||||||||||||||||||||||||||||||||||
10.5  : |||||||||||||||||||||||
10.75 : ||||||||
11.0  : |
11.25 :
----------
|bar chart>
Basically maps spikes to Gaussian smoothed spikes. Which is exactly what we need for this post. Now, let's generate our smoothed spike waves:
  smooth-spike-op |*> #=> smooth[0.25]^5 spikes |_self>
  map[smooth-spike-op,smoothed-spikes] rel-kets[spikes]
Now, define a couple of operators:
-- the float-value operator, to define our sort order:
  float-value |*> #=> pop-float clean |_self>

-- the show the wave operator:
  show-smoothed-spike-wave |*> #=> bar-chart[50] select[1,45] sort-by[float-value] smoothed-spikes (|empty> + |_self>)
Now, look at the waves, and note they are no longer spikes, but Gaussian smoothed spikes:
sa: show-smoothed-spike-wave |wave-1>
----------
-1.25 :
-1.0  : |
-0.75 : ||||||||
-0.5  : ||||||||||||||||||||||
-0.25 : ||||||||||||||||||||||||||||||||||||||
0.0   : ||||||||||||||||||||||||||||||||||||||||||||||||
0.25  : ||||||||||||||||||||||||||||||||||||||||||||||
0.5   : ||||||||||||||||||||||||||||||||||||||||||||
0.75  : |||||||||||||||||||||||||||||||||||||||||||||||
1.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
1.25  : |||||||||||||||||||||||||||||||||||||||||||||||
1.5   : ||||||||||||||||||||||||||||||||||||||||||||
1.75  : |||||||||||||||||||||||||||||||||||||||||||||||
2.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
2.25  : |||||||||||||||||||||||||||||||||||||||||||||||
2.5   : ||||||||||||||||||||||||||||||||||||||||||||
2.75  : |||||||||||||||||||||||||||||||||||||||||||||||
3.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
3.25  : |||||||||||||||||||||||||||||||||||||||||||||||
3.5   : ||||||||||||||||||||||||||||||||||||||||||||
3.75  : |||||||||||||||||||||||||||||||||||||||||||||||
4.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
4.25  : |||||||||||||||||||||||||||||||||||||||||||||||
4.5   : ||||||||||||||||||||||||||||||||||||||||||||
4.75  : |||||||||||||||||||||||||||||||||||||||||||||||
5.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
5.25  : |||||||||||||||||||||||||||||||||||||||||||||||
5.5   : ||||||||||||||||||||||||||||||||||||||||||||
5.75  : |||||||||||||||||||||||||||||||||||||||||||||||
6.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
6.25  : |||||||||||||||||||||||||||||||||||||||||||||||
6.5   : ||||||||||||||||||||||||||||||||||||||||||||
6.75  : |||||||||||||||||||||||||||||||||||||||||||||||
7.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
7.25  : |||||||||||||||||||||||||||||||||||||||||||||||
7.5   : ||||||||||||||||||||||||||||||||||||||||||||
7.75  : |||||||||||||||||||||||||||||||||||||||||||||||
8.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
8.25  : |||||||||||||||||||||||||||||||||||||||||||||||
8.5   : ||||||||||||||||||||||||||||||||||||||||||||
8.75  : |||||||||||||||||||||||||||||||||||||||||||||||
9.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
9.25  : |||||||||||||||||||||||||||||||||||||||||||||||
9.5   : ||||||||||||||||||||||||||||||||||||||||||||
9.75  : |||||||||||||||||||||||||||||||||||||||||||||||
----------

sa: show-smoothed-spike-wave |wave-2>
----------
-1.25 :
-1.0  : |
-0.75 : ||||||||
-0.5  : |||||||||||||||||||||||
-0.25 : |||||||||||||||||||||||||||||||||||||||||
0.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
0.25  : |||||||||||||||||||||||||||||||||||||||||
0.5   : |||||||||||||||||||||||
0.75  : |||||||||
1.0   : |||
1.25  : |||||||||
1.5   : |||||||||||||||||||||||
1.75  : |||||||||||||||||||||||||||||||||||||||||
2.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
2.25  : |||||||||||||||||||||||||||||||||||||||||
2.5   : |||||||||||||||||||||||
2.75  : |||||||||
3.0   : |||
3.25  : |||||||||
3.5   : |||||||||||||||||||||||
3.75  : |||||||||||||||||||||||||||||||||||||||||
4.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
4.25  : |||||||||||||||||||||||||||||||||||||||||
4.5   : |||||||||||||||||||||||
4.75  : |||||||||
5.0   : |||
5.25  : |||||||||
5.5   : |||||||||||||||||||||||
5.75  : |||||||||||||||||||||||||||||||||||||||||
6.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
6.25  : |||||||||||||||||||||||||||||||||||||||||
6.5   : |||||||||||||||||||||||
6.75  : |||||||||
7.0   : |||
7.25  : |||||||||
7.5   : |||||||||||||||||||||||
7.75  : |||||||||||||||||||||||||||||||||||||||||
8.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
8.25  : |||||||||||||||||||||||||||||||||||||||||
8.5   : |||||||||||||||||||||||
8.75  : |||||||||
9.0   : |||
9.25  : |||||||||
9.5   : |||||||||||||||||||||||
9.75  : |||||||||||||||||||||||||||||||||||||||||
----------

sa: show-smoothed-spike-wave |wave-3>
----------
-1.25 :
-1.0  : |
-0.75 : ||||||||
-0.5  : |||||||||||||||||||||||
-0.25 : |||||||||||||||||||||||||||||||||||||||||
0.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
0.25  : |||||||||||||||||||||||||||||||||||||||||
0.5   : |||||||||||||||||||||||
0.75  : ||||||||
1.0   : |
1.25  :
1.5   :
1.75  :
2.0   : |
2.25  : ||||||||
2.5   : |||||||||||||||||||||||
2.75  : |||||||||||||||||||||||||||||||||||||||||
3.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
3.25  : |||||||||||||||||||||||||||||||||||||||||
3.5   : |||||||||||||||||||||||
3.75  : ||||||||
4.0   : |
4.25  :
4.5   :
4.75  :
5.0   : |
5.25  : ||||||||
5.5   : |||||||||||||||||||||||
5.75  : |||||||||||||||||||||||||||||||||||||||||
6.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
6.25  : |||||||||||||||||||||||||||||||||||||||||
6.5   : |||||||||||||||||||||||
6.75  : ||||||||
7.0   : |
7.25  :
7.5   :
7.75  :
8.0   : |
8.25  : ||||||||
8.5   : |||||||||||||||||||||||
8.75  : |||||||||||||||||||||||||||||||||||||||||
9.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
9.25  : |||||||||||||||||||||||||||||||||||||||||
9.5   : |||||||||||||||||||||||
9.75  : ||||||||
----------

sa: show-smoothed-spike-wave |wave-7>
----------
-1.25 :
-1.0  : |
-0.75 : ||||||||
-0.5  : |||||||||||||||||||||||
-0.25 : |||||||||||||||||||||||||||||||||||||||||
0.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
0.25  : |||||||||||||||||||||||||||||||||||||||||
0.5   : |||||||||||||||||||||||
0.75  : ||||||||
1.0   : |
1.25  :
1.5   :
1.75  :
2.0   :
2.25  :
2.5   :
2.75  :
3.0   :
3.25  :
3.5   :
3.75  :
4.0   :
4.25  :
4.5   :
4.75  :
5.0   :
5.25  :
5.5   :
5.75  :
6.0   : |
6.25  : ||||||||
6.5   : |||||||||||||||||||||||
6.75  : |||||||||||||||||||||||||||||||||||||||||
7.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
7.25  : |||||||||||||||||||||||||||||||||||||||||
7.5   : |||||||||||||||||||||||
7.75  : ||||||||
8.0   : |
8.25  :
8.5   :
8.75  :
9.0   :
9.25  :
9.5   :
9.75  :
----------
OK. All nice and pretty. Now we want to look at their similarities. Presumably, for integers they should give very similar similarities as the single spike versions. Only for off-integer spikes should there be a big difference. Let's see what the data says:
-- define our show similarity operator:
  show-smoothed-similarity |*> #=> bar-chart[50] ket-sort similar-input[smoothed-spikes] smoothed-spikes |_self>

-- now put it to use:
sa: show-smoothed-similarity |wave-1>
----------
wave-1  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-2  : ||||||||||||||||||||||||||||||||||||
wave-3  : ||||||||||||||||||||||||||
wave-4  : ||||||||||||||||||||
wave-5  : |||||||||||||||||
wave-6  : |||||||||||||||
wave-7  : |||||||||||||
wave-8  : |||||||||||
wave-9  : ||||||||||
wave-10 : |||||||||
wave-11 : ||||||||
wave-12 : ||||||||
wave-13 : |||||||
wave-14 : |||||||
wave-15 : ||||||
wave-16 : ||||||
wave-17 : ||||||
wave-18 : |||||
wave-19 : |||||
wave-20 : |||||
----------

sa: show-smoothed-similarity |wave-2>
----------
wave-1  : ||||||||||||||||||||||||||||||||||||
wave-2  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-3  : |||||||||||||||||||||||||
wave-4  : |||||||||||||||||||||||||
wave-5  : ||||||||||||||||
wave-6  : |||||||||||||||||
wave-7  : ||||||||||||
wave-8  : ||||||||||||
wave-9  : ||||||||||
wave-10 : ||||||||||
wave-11 : ||||||||
wave-12 : ||||||||
wave-13 : |||||||
wave-14 : |||||||
wave-15 : ||||||
wave-16 : ||||||
wave-17 : |||||
wave-18 : |||||
wave-19 : |||||
wave-20 : |||||
----------

sa: show-smoothed-similarity |wave-3>
----------
wave-1  : ||||||||||||||||||||||||||
wave-2  : |||||||||||||||||||||||||
wave-3  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-4  : ||||||||||||||||||
wave-5  : |||||||||||||||
wave-6  : |||||||||||||||||||||||||
wave-7  : |||||||||||
wave-8  : ||||||||||
wave-9  : ||||||||||||||||
wave-10 : ||||||||
wave-11 : ||||||||
wave-12 : ||||||||||||
wave-13 : |||||||
wave-14 : ||||||
wave-15 : ||||||||||
wave-16 : |||||
wave-17 : |||||
wave-18 : ||||||||
wave-19 : |||||
wave-20 : ||||
----------

sa: show-smoothed-similarity |wave-4>
----------
wave-1  : ||||||||||||||||||||
wave-2  : |||||||||||||||||||||||||
wave-3  : ||||||||||||||||||
wave-4  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-5  : |||||||||||||||
wave-6  : |||||||||||||||||
wave-7  : |||||||||||
wave-8  : |||||||||||||||||||||||||
wave-9  : |||||||||
wave-10 : ||||||||||
wave-11 : |||||||
wave-12 : ||||||||||||||||
wave-13 : ||||||
wave-14 : |||||||
wave-15 : |||||
wave-16 : ||||||||||||
wave-17 : |||||
wave-18 : |||||
wave-19 : |||||
wave-20 : ||||||||||
----------

sa: show-smoothed-similarity |wave-5>
----------
wave-1  : |||||||||||||||||
wave-2  : ||||||||||||||||
wave-3  : |||||||||||||||
wave-4  : |||||||||||||||
wave-5  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-6  : ||||||||||||
wave-7  : ||||||||||
wave-8  : |||||||||
wave-9  : ||||||||
wave-10 : |||||||||||||||||||||||||
wave-11 : |||||||
wave-12 : ||||||
wave-13 : ||||||
wave-14 : ||||||
wave-15 : ||||||||||||||||
wave-16 : |||||
wave-17 : |||||
wave-18 : |||||
wave-19 : ||||
wave-20 : ||||||||||||
----------

sa: show-smoothed-similarity |wave-6>
----------
wave-1  : |||||||||||||||
wave-2  : |||||||||||||||||
wave-3  : |||||||||||||||||||||||||
wave-4  : |||||||||||||||||
wave-5  : ||||||||||||
wave-6  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-7  : ||||||||||
wave-8  : ||||||||||||
wave-9  : ||||||||||||||||
wave-10 : ||||||||||
wave-11 : |||||||
wave-12 : |||||||||||||||||||||||||
wave-13 : ||||||
wave-14 : |||||||
wave-15 : ||||||||||
wave-16 : ||||||
wave-17 : ||||
wave-18 : ||||||||||||||||
wave-19 : ||||
wave-20 : |||||
----------

sa: show-smoothed-similarity |wave-7>
----------
wave-1  : |||||||||||||
wave-2  : ||||||||||||
wave-3  : |||||||||||
wave-4  : |||||||||||
wave-5  : ||||||||||
wave-6  : ||||||||||
wave-7  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-8  : |||||||||
wave-9  : ||||||||
wave-10 : |||||||
wave-11 : |||||||
wave-12 : ||||||
wave-13 : ||||||
wave-14 : |||||||||||||||||||||||||
wave-15 : |||||
wave-16 : |||||
wave-17 : |||||
wave-18 : ||||
wave-19 : ||||
wave-20 : ||||
----------

sa: show-smoothed-similarity |wave-8>
----------
wave-1  : |||||||||||
wave-2  : ||||||||||||
wave-3  : ||||||||||
wave-4  : |||||||||||||||||||||||||
wave-5  : |||||||||
wave-6  : ||||||||||||
wave-7  : |||||||||
wave-8  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-9  : ||||||||
wave-10 : ||||||||||
wave-11 : |||||||
wave-12 : ||||||||||||||||
wave-13 : ||||||
wave-14 : |||||||
wave-15 : |||||
wave-16 : |||||||||||||||||||||||||
wave-17 : ||||
wave-18 : |||||
wave-19 : ||||
wave-20 : ||||||||||
----------

sa: show-smoothed-similarity |wave-9>
----------
wave-1  : ||||||||||
wave-2  : ||||||||||
wave-3  : ||||||||||||||||
wave-4  : |||||||||
wave-5  : ||||||||
wave-6  : ||||||||||||||||
wave-7  : ||||||||
wave-8  : ||||||||
wave-9  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-10 : |||||||
wave-11 : |||||||
wave-12 : ||||||||||||
wave-13 : ||||||
wave-14 : |||||
wave-15 : ||||||||||
wave-16 : ||||
wave-17 : ||||
wave-18 : |||||||||||||||||||||||||
wave-19 : ||||
wave-20 : ||||
----------

sa: show-smoothed-similarity |wave-10>
----------
wave-1  : |||||||||
wave-2  : ||||||||||
wave-3  : ||||||||
wave-4  : ||||||||||
wave-5  : |||||||||||||||||||||||||
wave-6  : ||||||||||
wave-7  : |||||||
wave-8  : ||||||||||
wave-9  : |||||||
wave-10 : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-11 : |||||||
wave-12 : ||||||||
wave-13 : |||||
wave-14 : |||||||
wave-15 : ||||||||||||||||
wave-16 : ||||||
wave-17 : ||||
wave-18 : ||||||
wave-19 : ||||
wave-20 : |||||||||||||||||||||||||
----------

sa: show-smoothed-similarity |wave-11>
----------
wave-1  : ||||||||
wave-2  : ||||||||
wave-3  : ||||||||
wave-4  : |||||||
wave-5  : |||||||
wave-6  : |||||||
wave-7  : |||||||
wave-8  : |||||||
wave-9  : |||||||
wave-10 : |||||||
wave-11 : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-12 : ||||||
wave-13 : |||||
wave-14 : |||||
wave-15 : |||||
wave-16 : ||||
wave-17 : ||||
wave-18 : ||||
wave-19 : ||||
wave-20 : ||||
----------

sa: show-smoothed-similarity |wave-12>
----------
wave-1  : ||||||||
wave-2  : ||||||||
wave-3  : ||||||||||||
wave-4  : ||||||||||||||||
wave-5  : ||||||
wave-6  : |||||||||||||||||||||||||
wave-7  : ||||||
wave-8  : ||||||||||||||||
wave-9  : ||||||||||||
wave-10 : ||||||||
wave-11 : ||||||
wave-12 : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-13 : ||||||
wave-14 : |||||||
wave-15 : ||||||||||
wave-16 : ||||||||||||
wave-17 : ||||
wave-18 : ||||||||||||||||
wave-19 : ||||
wave-20 : ||||||||||
----------
Which is roughly the same as the spike version, though wave-2 looks distinctly different, and wave-k for prime k have slightly higher similarity than in the spike version. But the thing we really want to test are non-integer wave's. Here is |wave-9.75>:
sa: show-smoothed-spike-wave |wave-9.75>
----------
-1.25 :
-1.0  : |
-0.75 : ||||||||
-0.5  : |||||||||||||||||||||||
-0.25 : |||||||||||||||||||||||||||||||||||||||||
0.0   : ||||||||||||||||||||||||||||||||||||||||||||||||||
0.25  : |||||||||||||||||||||||||||||||||||||||||
0.5   : |||||||||||||||||||||||
0.75  : ||||||||
1.0   : |
1.25  :
1.5   :
1.75  :
2.0   :
2.25  :
2.5   :
2.75  :
3.0   :
3.25  :
3.5   :
3.75  :
4.0   :
4.25  :
4.5   :
4.75  :
5.0   :
5.25  :
5.5   :
5.75  :
6.0   :
6.25  :
6.5   :
6.75  :
7.0   :
7.25  :
7.5   :
7.75  :
8.0   :
8.25  :
8.5   :
8.75  : |
9.0   : ||||||||
9.25  : |||||||||||||||||||||||
9.5   : |||||||||||||||||||||||||||||||||||||||||
9.75  : ||||||||||||||||||||||||||||||||||||||||||||||||||
----------

sa: show-smoothed-similarity |wave-9.75>
----------
wave-1    : ||||||||||
wave-2    : |||||||||
wave-3    : ||||||||
wave-4    : ||||||||
wave-5    : ||||||||
wave-6    : |||||||
wave-7    : |||||||
wave-8    : |||||||
wave-9    : |||||||
wave-9.75 : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-10   : ||||||
wave-11   : ||||||
wave-12   : ||||||
wave-13   : ||||||||||||
wave-14   : |||||
wave-15   : |||||
wave-16   : ||||
wave-17   : ||||
wave-18   : ||||
wave-19   : ||||
wave-20   : ||||
----------
vs the spike similarity:
sa: show-similarity |wave-9.75>
----------
wave-9.75 : ||||||||||||||||||||||||||||||||||||||||||||||||||
----------
Which is pretty much my point. The smoothed spike transform is more tolerant of the spikes not being at exact integer spacing's. And for that reason, in practice should be more useful, because brains are not expected to be ultra precise.

BTW, we have two parameters we can tweak. Recall the smooth spike operator:
  smooth-spike-op |*> #=> smooth[0.25]^5 spikes |_self>
In particular, note the smooth[dx]^k term. We can tweak both dx and k, with the result that we can tweak the shape/width of our Gaussian spikes. For example keeping track of music would require narrower spikes than in other contexts.

spike wave similarity

Today, revisiting an old post. I've made a lot of progress since then, and I think I can now produce a better example of what I was trying to show. The idea is simple enough. Given a spikey wave-shape, let's take a look at their similarity to other spikey wave-shapes. The motivation being that the brain probably does something similar. The brain certainly has spikey waves, that is obvious enough. And I claim the brain does something very similar to my similarity metric. Though I'm not yet clear on an application for spikey wave similarity.

Now, define our spike waves using the range function (NB: the last term in the range function is the step size):
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>)
spikes |wave-16> => range(|0>,|1000>,|16>)
spikes |wave-17> => range(|0>,|1000>,|17>)
spikes |wave-18> => range(|0>,|1000>,|18>)
spikes |wave-19> => range(|0>,|1000>,|19>)
spikes |wave-20> => range(|0>,|1000>,|20>)
spikes |empty> => 0 spikes |wave-1>
And a couple of operators to examine this knowledge:
show-spike-wave |*> #=> bar-chart[50] select[1,30] ket-sort spikes (|empty> + |_self>)
show-similarity |*> #=> bar-chart[50] ket-sort similar-input[spikes] spikes |_self>
Let's visualize our spike waves:
sa: show-spike-wave |wave-1>
----------
0  : ||||||||||||||||||||||||||||||||||||||||||||||||||
1  : ||||||||||||||||||||||||||||||||||||||||||||||||||
2  : ||||||||||||||||||||||||||||||||||||||||||||||||||
3  : ||||||||||||||||||||||||||||||||||||||||||||||||||
4  : ||||||||||||||||||||||||||||||||||||||||||||||||||
5  : ||||||||||||||||||||||||||||||||||||||||||||||||||
6  : ||||||||||||||||||||||||||||||||||||||||||||||||||
7  : ||||||||||||||||||||||||||||||||||||||||||||||||||
8  : ||||||||||||||||||||||||||||||||||||||||||||||||||
9  : ||||||||||||||||||||||||||||||||||||||||||||||||||
10 : ||||||||||||||||||||||||||||||||||||||||||||||||||
11 : ||||||||||||||||||||||||||||||||||||||||||||||||||
12 : ||||||||||||||||||||||||||||||||||||||||||||||||||
13 : ||||||||||||||||||||||||||||||||||||||||||||||||||
14 : ||||||||||||||||||||||||||||||||||||||||||||||||||
15 : ||||||||||||||||||||||||||||||||||||||||||||||||||
16 : ||||||||||||||||||||||||||||||||||||||||||||||||||
17 : ||||||||||||||||||||||||||||||||||||||||||||||||||
18 : ||||||||||||||||||||||||||||||||||||||||||||||||||
19 : ||||||||||||||||||||||||||||||||||||||||||||||||||
20 : ||||||||||||||||||||||||||||||||||||||||||||||||||
21 : ||||||||||||||||||||||||||||||||||||||||||||||||||
22 : ||||||||||||||||||||||||||||||||||||||||||||||||||
23 : ||||||||||||||||||||||||||||||||||||||||||||||||||
24 : ||||||||||||||||||||||||||||||||||||||||||||||||||
25 : ||||||||||||||||||||||||||||||||||||||||||||||||||
26 : ||||||||||||||||||||||||||||||||||||||||||||||||||
27 : ||||||||||||||||||||||||||||||||||||||||||||||||||
28 : ||||||||||||||||||||||||||||||||||||||||||||||||||
29 : ||||||||||||||||||||||||||||||||||||||||||||||||||
----------
|bar chart>

sa: show-spike-wave |wave-2>
----------
0  : ||||||||||||||||||||||||||||||||||||||||||||||||||
1  :
2  : ||||||||||||||||||||||||||||||||||||||||||||||||||
3  :
4  : ||||||||||||||||||||||||||||||||||||||||||||||||||
5  :
6  : ||||||||||||||||||||||||||||||||||||||||||||||||||
7  :
8  : ||||||||||||||||||||||||||||||||||||||||||||||||||
9  :
10 : ||||||||||||||||||||||||||||||||||||||||||||||||||
11 :
12 : ||||||||||||||||||||||||||||||||||||||||||||||||||
13 :
14 : ||||||||||||||||||||||||||||||||||||||||||||||||||
15 :
16 : ||||||||||||||||||||||||||||||||||||||||||||||||||
17 :
18 : ||||||||||||||||||||||||||||||||||||||||||||||||||
19 :
20 : ||||||||||||||||||||||||||||||||||||||||||||||||||
21 :
22 : ||||||||||||||||||||||||||||||||||||||||||||||||||
23 :
24 : ||||||||||||||||||||||||||||||||||||||||||||||||||
25 :
26 : ||||||||||||||||||||||||||||||||||||||||||||||||||
27 :
28 : ||||||||||||||||||||||||||||||||||||||||||||||||||
29 :
----------
|bar chart>

sa: show-spike-wave |wave-3>
----------
0  : ||||||||||||||||||||||||||||||||||||||||||||||||||
1  :
2  :
3  : ||||||||||||||||||||||||||||||||||||||||||||||||||
4  :
5  :
6  : ||||||||||||||||||||||||||||||||||||||||||||||||||
7  :
8  :
9  : ||||||||||||||||||||||||||||||||||||||||||||||||||
10 :
11 :
12 : ||||||||||||||||||||||||||||||||||||||||||||||||||
13 :
14 :
15 : ||||||||||||||||||||||||||||||||||||||||||||||||||
16 :
17 :
18 : ||||||||||||||||||||||||||||||||||||||||||||||||||
19 :
20 :
21 : ||||||||||||||||||||||||||||||||||||||||||||||||||
22 :
23 :
24 : ||||||||||||||||||||||||||||||||||||||||||||||||||
25 :
26 :
27 : ||||||||||||||||||||||||||||||||||||||||||||||||||
28 :
29 :
----------
|bar chart>

sa: show-spike-wave |wave-7>
----------
0  : ||||||||||||||||||||||||||||||||||||||||||||||||||
1  :
2  :
3  :
4  :
5  :
6  :
7  : ||||||||||||||||||||||||||||||||||||||||||||||||||
8  :
9  :
10 :
11 :
12 :
13 :
14 : ||||||||||||||||||||||||||||||||||||||||||||||||||
15 :
16 :
17 :
18 :
19 :
20 :
21 : ||||||||||||||||||||||||||||||||||||||||||||||||||
22 :
23 :
24 :
25 :
26 :
27 :
28 : ||||||||||||||||||||||||||||||||||||||||||||||||||
29 :
----------
|bar chart>
Now the interesting bit, visualizing their similarity:
sa: show-similarity |wave-1>
----------
wave-1  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-2  : |||||||||||||||||||||||||
wave-3  : ||||||||||||||||
wave-4  : ||||||||||||
wave-5  : ||||||||||
wave-6  : ||||||||
wave-7  : |||||||
wave-8  : ||||||
wave-9  : |||||
wave-10 : |||||
wave-11 : ||||
wave-12 : ||||
wave-13 : |||
wave-14 : |||
wave-15 : |||
wave-16 : |||
wave-17 : ||
wave-18 : ||
wave-19 : ||
wave-20 : ||
----------
|bar chart>

sa: show-similarity |wave-2>
----------
wave-1  : |||||||||||||||||||||||||
wave-2  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-3  : ||||||||||||||||
wave-4  : |||||||||||||||||||||||||
wave-5  : ||||||||||
wave-6  : ||||||||||||||||
wave-7  : |||||||
wave-8  : ||||||||||||
wave-9  : |||||
wave-10 : ||||||||||
wave-11 : ||||
wave-12 : ||||||||
wave-13 : |||
wave-14 : |||||||
wave-15 : |||
wave-16 : ||||||
wave-17 : ||
wave-18 : |||||
wave-19 : ||
wave-20 : |||||
----------
|bar chart>

sa: show-similarity |wave-3>
----------
wave-1  : ||||||||||||||||
wave-2  : ||||||||||||||||
wave-3  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-4  : ||||||||||||
wave-5  : ||||||||||
wave-6  : |||||||||||||||||||||||||
wave-7  : |||||||
wave-8  : ||||||
wave-9  : ||||||||||||||||
wave-10 : |||||
wave-11 : ||||
wave-12 : ||||||||||||
wave-13 : |||
wave-14 : |||
wave-15 : ||||||||||
wave-16 : |||
wave-17 : ||
wave-18 : ||||||||
wave-19 : ||
wave-20 : ||
----------
|bar chart>

sa: show-similarity |wave-4>
----------
wave-1  : ||||||||||||
wave-2  : |||||||||||||||||||||||||
wave-3  : ||||||||||||
wave-4  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-5  : ||||||||||
wave-6  : ||||||||||||||||
wave-7  : |||||||
wave-8  : |||||||||||||||||||||||||
wave-9  : |||||
wave-10 : ||||||||||
wave-11 : ||||
wave-12 : ||||||||||||||||
wave-13 : |||
wave-14 : |||||||
wave-15 : |||
wave-16 : ||||||||||||
wave-17 : ||
wave-18 : |||||
wave-19 : ||
wave-20 : ||||||||||
----------
|bar chart>

sa: show-similarity |wave-5>
----------
wave-1  : ||||||||||
wave-2  : ||||||||||
wave-3  : ||||||||||
wave-4  : ||||||||||
wave-5  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-6  : ||||||||
wave-7  : |||||||
wave-8  : ||||||
wave-9  : |||||
wave-10 : |||||||||||||||||||||||||
wave-11 : ||||
wave-12 : ||||
wave-13 : |||
wave-14 : |||
wave-15 : ||||||||||||||||
wave-16 : |||
wave-17 : ||
wave-18 : ||
wave-19 : ||
wave-20 : ||||||||||||
----------
|bar chart>

sa: show-similarity |wave-6>
----------
wave-1  : ||||||||
wave-2  : ||||||||||||||||
wave-3  : |||||||||||||||||||||||||
wave-4  : ||||||||||||||||
wave-5  : ||||||||
wave-6  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-7  : |||||||
wave-8  : ||||||||||||
wave-9  : ||||||||||||||||
wave-10 : ||||||||||
wave-11 : ||||
wave-12 : |||||||||||||||||||||||||
wave-13 : |||
wave-14 : |||||||
wave-15 : ||||||||||
wave-16 : ||||||
wave-17 : ||
wave-18 : ||||||||||||||||
wave-19 : ||
wave-20 : |||||
----------
|bar chart>

sa: show-similarity |wave-7>
----------
wave-1  : |||||||
wave-2  : |||||||
wave-3  : |||||||
wave-4  : |||||||
wave-5  : |||||||
wave-6  : |||||||
wave-7  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-8  : ||||||
wave-9  : |||||
wave-10 : |||||
wave-11 : ||||
wave-12 : ||||
wave-13 : |||
wave-14 : |||||||||||||||||||||||||
wave-15 : |||
wave-16 : |||
wave-17 : |||
wave-18 : ||
wave-19 : ||
wave-20 : ||
----------
|bar chart>

sa: show-similarity |wave-8>
----------
wave-1  : ||||||
wave-2  : ||||||||||||
wave-3  : ||||||
wave-4  : |||||||||||||||||||||||||
wave-5  : ||||||
wave-6  : ||||||||||||
wave-7  : ||||||
wave-8  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-9  : |||||
wave-10 : ||||||||||
wave-11 : ||||
wave-12 : ||||||||||||||||
wave-13 : |||
wave-14 : |||||||
wave-15 : |||
wave-16 : |||||||||||||||||||||||||
wave-17 : |||
wave-18 : |||||
wave-19 : ||
wave-20 : ||||||||||
----------
|bar chart>

sa: show-similarity |wave-9>
----------
wave-1  : |||||
wave-2  : |||||
wave-3  : ||||||||||||||||
wave-4  : |||||
wave-5  : |||||
wave-6  : ||||||||||||||||
wave-7  : |||||
wave-8  : |||||
wave-9  : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-10 : |||||
wave-11 : ||||
wave-12 : ||||||||||||
wave-13 : ||||
wave-14 : |||
wave-15 : ||||||||||
wave-16 : |||
wave-17 : |||
wave-18 : |||||||||||||||||||||||||
wave-19 : ||
wave-20 : ||
----------
|bar chart>

sa: show-similarity |wave-10>
----------
wave-1  : |||||
wave-2  : ||||||||||
wave-3  : |||||
wave-4  : ||||||||||
wave-5  : |||||||||||||||||||||||||
wave-6  : ||||||||||
wave-7  : |||||
wave-8  : ||||||||||
wave-9  : |||||
wave-10 : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-11 : ||||
wave-12 : ||||||||
wave-13 : |||
wave-14 : |||||||
wave-15 : ||||||||||||||||
wave-16 : ||||||
wave-17 : ||
wave-18 : |||||
wave-19 : ||
wave-20 : |||||||||||||||||||||||||
----------
|bar chart>

sa: show-similarity |wave-11>
----------
wave-1  : ||||
wave-2  : ||||
wave-3  : ||||
wave-4  : ||||
wave-5  : ||||
wave-6  : ||||
wave-7  : ||||
wave-8  : ||||
wave-9  : ||||
wave-10 : ||||
wave-11 : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-12 : ||||
wave-13 : |||
wave-14 : |||
wave-15 : |||
wave-16 : |||
wave-17 : |||
wave-18 : |||
wave-19 : ||
wave-20 : ||
----------
|bar chart>

sa: show-similarity |wave-12>
----------
wave-1  : ||||
wave-2  : ||||||||
wave-3  : ||||||||||||
wave-4  : ||||||||||||||||
wave-5  : ||||
wave-6  : |||||||||||||||||||||||||
wave-7  : ||||
wave-8  : ||||||||||||||||
wave-9  : ||||||||||||
wave-10 : ||||||||
wave-11 : ||||
wave-12 : ||||||||||||||||||||||||||||||||||||||||||||||||||
wave-13 : ||||
wave-14 : |||||||
wave-15 : ||||||||||
wave-16 : ||||||||||||
wave-17 : ||
wave-18 : ||||||||||||||||
wave-19 : ||
wave-20 : ||||||||||
----------
|bar chart>
Now some notes:
1) signals from primes are very strong in these similarity graphs! Prime waves have very low similarity with other waves, and non-prime waves have very high similarity with waves that share factors. eg, wave-11 has very low similarity with the other 19 waves, though it is non-zero because of the initial spike at 0. And wave-12 has high similarity with {6,4,8,18,3,9,16,...} in that order. And very low similarity with {5,7,11,13,17,19}.
2) technically these are spatial waves, not time sequences of spikes since they are superpositions not sequences. I presume, but haven't given it much thought, that the brain can easily convert a time sequence of spikes into a spatial spike wave. Alternatively I should finally find a similarity measure for sequences, not just the current superposition version.
3) perhaps one use for this "spike Fourier transform" would be to convert some arbitrary spike pattern into its frequency (ie, wave-k) components. Though I don't currently know of a concrete use for this. Certainly our ears do a type of Fourier transform, but I think that is a physical thing using vibrating hairs, not a neuron processing thing.
4) I wonder if something similar can be used to measure distances between spikes? If we line it up so the starting spike is at zero, then if there is a spike at time k later, the wave-k neuron should activate. One possible application of measuring distances, but there are many others, would be when analysing a face. ie, distances between the various features in faces as a nice object to superposition mapping.
5) presumably this has some relevance to music.
6) note, the above version is very exacting. The spikes must be exactly integers, else you get no match. Consider steps of size 9.9, and hoping it has some similarity with step size 10:
sa: spikes |wave-9.9> => range(|0>,|1000>,|9.9>)
sa: show-similarity |wave-9.9>
----------
wave-9.9 : ||||||||||||||||||||||||||||||||||||||||||||||||||
----------
|bar chart>
ie, 0 similarity with our integer spikes. If we don't want that behaviour then we need to smooth our spike transforms. Let's call that a "smoothed spike Fourier transform". This post is too long, so let's do that in a new post.
7) the idea should carry over in an obvious way to spike trains that are not perfectly periodic. Periodic spike trains are just the simplest to consider, because they are so easy to define using the range function, and have the most in common with standard Fourier transforms.

Tuesday 20 September 2016

new operator: words-to-list

Today, a brief mention of a new operator. Yeah, I need to record my function operators somewhere, and so far I've been using this blog. Eventually I need a nice tidy document that explains them all. Anyway, the point of this one is a small step towards converting incoming English into back-end BKO. But only a small step. We already have the list-to-words operator, and now here is the inverse.

Let the console explain. First the existing list-to-words operator:
sa: list-to-words |a>
|a>

sa: list-to-words (|a> + |b>)
|a and b>

sa: list-to-words (|a> + |b> + |c>)
|a, b and c>

sa: list-to-words (|a> + |b> + |c> + |d>)
|a, b, c and d>
And so on. Now the inverse, words-to-list:
sa: words-to-list |a>
|a>

sa: words-to-list |a and b>
|a> + |b>

sa: words-to-list |a, b and c>
|a> + |b> + |c>

sa: words-to-list |a, b, c and d>
|a> + |b> + |c> + |d>
OK. So kind of abstract. But we can sub in more meaningful words into our word lists. Let's say a person is hungry, tired and sleepy:
-- learn it:
sa: my-current |mood> => words-to-list |hungry, tired and sleepy>

-- recall it:
sa: my-current |mood>
|hungry> + |tired> + |sleepy>
Anyway, makes inputting a superposition a little cleaner, and more like natural English. BTW, they are actually perfect inverses:
sa: list-to-words words-to-list |a, b, c, d and e>
|a, b, c, d and e>

sa: words-to-list list-to-words (|a> + |b> + |c> + |d> + |e>)
|a> + |b> + |c> + |d> + |e>
That's it for this post.

Monday 12 September 2016

new function operator: bar-chart

Today I implemented a nice ASCII visualization for superpositions. The bar-chart operator. The intention is to make the results easier to read than the raw superpositions. Previously I used "table[ket,coeff]" to do something similar, but this makes a nice addition, and was only a few lines of code. Now, I need a nice worked example for this thing. How about the dog/cat example from the other day?

Load up some knowledge:
  context animal sound SDR's
  full |range> => range(|1>,|100>)
  encode |purring> => pick[5] full |range>
  encode |miaowing> => pick[5] full |range>
  encode |scratching at the door> => pick[5] full |range>
  encode |panting> => pick[5] full |range>
  encode |sniffing> => pick[5] full |range>

  sounds-it-makes |cat> => union[encode] (|purring> + |miaowing> + |scratching at the door>)
  sounds-it-makes |dog> => union[encode] (|panting> + |sniffing> + |scratching at the door>)
Now put the bar-chart[width] operator to use:
-- given scratching at the door predict dog or cat:
sa: bar-chart[50] similar-input[sounds-it-makes] encode |scratching at the door>
----------
dog : ||||||||||||||||||||||||||||||||||||||||||||||||||
cat : ||||||||||||||||||||||||||||||||||||||||||||||
----------
|bar chart>

-- given scratching and sniffing, predict dog or cat:
sa: bar-chart[50] similar-input[sounds-it-makes] encode (|scratching at the door> + |sniffing>)
----------
dog : ||||||||||||||||||||||||||||||||||||||||||||||||||
cat : |||||||||||||||||||||||
----------
|bar chart>

-- given panting, predict what other sounds are next:
sa: bar-chart[50] similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |panting>
----------
scratching at the door : ||||||||||||||||||||||||||||||||||||||||||||||||||
panting                : ||||||||||||||||||||||||||||||||||||||||||||||||||
sniffing               : ||||||||||||||||||||||||||||||||||||||||||||||||||
purring                : ||||||||||
----------
|bar chart>

-- given purring, predict what other sounds are next:
sa: bar-chart[50] similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |purring>
----------
scratching at the door : ||||||||||||||||||||||||||||||||||||||||||||||||||
purring                : ||||||||||||||||||||||||||||||||||||||||||
miaowing               : |||||||||||||||||||||||||||||||||||||||||
panting                : ||||||||
sniffing               : ||||||||
----------
|bar chart>

-- finally, given scratching, predict what other sounds are next:
sa: bar-chart[50] similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |scratching at the door>
----------
scratching at the door : ||||||||||||||||||||||||||||||||||||||||||||||||||
purring                : |||||||||||||||||||||||||||||
panting                : |||||||||||||||||||||||||
sniffing               : |||||||||||||||||||||||||
miaowing               : ||||||||||||||||||||||||
----------
|bar chart>
So with this, it is now much easier to understand the relative coefficients in our superpositions. And yeah, highlights that superpositions are pretty boring by themselves. Bar charts have been around for ever! The point of my project is that a lot of things become easy if we use superpositions as the fundamental data-type, especially anything trying to reproduce the behaviour of neurons. Of course, much more power is added by operators, and the operator composition rule that maps superpositions to superpositions.

The other comment I need to make is that of "background noise". eg, note that panting also predicts purring, and purring predicts panting and sniffing, though they do have lower coefficients. This might not initially make sense, given that cat noises should not predict dog noises, and vice versa. But I don't think this is a problem. The brain makes similar mistakes, and has a similar solution, drop/ignore everything below some threshold. In the above example, drop-below[0.15] tidies up our results nicely.

Thursday 8 September 2016

identifying a face

In this blog post I want to reproduce the idea of if you see a part of a face, ie only a subset of face features, you can predict who it belongs to. Nothing too technical. Just something I wanted to do.
-- load up a frequency list of names from the US census:
load names.sw

-- for example sake, let's just consider the top 30 most common female names, and remove the associated frequency using the clean operator:
list-of |female names> => clean select[1,30] names |female name>

-- define a list of face features:
list-of |face features> => |eye type> + |ear type> + |nose type> + |chin type> + |lip type> + |cheek type> + |hair type> + |eyebrow type>

-- let's create a data-set, that maps female faces to feature types, 5 variations per type:
features-op |*> #=> random-column[5] list-of |face features>
map[features-op,features] list-of |female names>

-- check out a couple of examples in this new data-set:
sa: features |mary>
|eye type: 4> + |ear type: 3> + |nose type: 4> + |chin type: 3> + |lip type: 1> + |cheek type: 0> + |hair type: 1> + |eyebrow type: 4>

sa: features |sarah>
|eye type: 1> + |ear type: 0> + |nose type: 0> + |chin type: 2> + |lip type: 3> + |cheek type: 1> + |hair type: 2> + |eyebrow type: 3>

sa: features |laura>
|eye type: 4> + |ear type: 0> + |nose type: 4> + |chin type: 4> + |lip type: 4> + |cheek type: 4> + |hair type: 3> + |eyebrow type: 2>
Now put it to use:
-- given "eye type 3", "chin type 0" and "ear type 4" let's guess who it might be (as a percent):
sa: 100 similar-input[features] (|eye type: 3> + |chin type: 0> + |ear type: 4>)
25|carol> + 25|angela> + 12.5|linda> + 12.5|barbara> + 12.5|elizabeth> + 12.5|jennifer> + 12.5|maria> + 12.5|dorothy> + 12.5|karen> + 12.5|helen> + 12.5|donna> + 12.5|sharon> + 12.5|kimberly> + 12.5|deborah>

-- let's try again, this time with a few more features:
sa: 100 similar-input[features] (|ear type: 0> + |nose type: 4> + |lip type: 4> + |cheek type: 2> + |hair type: 3>)
50|laura> + 25|linda> + 25|elizabeth> + 25|jennifer> + 25|lisa> + 25|betty> + 25|donna> + 25|kimberly> + 25|melissa> + 12.5|mary> + 12.5|patricia> + 12.5|barbara> + 12.5|maria> + 12.5|susan> + 12.5|margaret> + 12.5|nancy> + 12.5|helen> + 12.5|ruth> + 12.5|sharon> + 12.5|sarah> + 12.5|deborah> + 12.5|angela>

-- now feed in features we know has an exact match:
sa: 100 similar-input[features] (|eye type: 4> + |ear type: 0> + |nose type: 4> + |chin type: 4> + |lip type: 4> + |cheek type: 4> + |hair type: 3> + |eyebrow type: 2>)
100|laura> + 62.5|lisa> + 50|elizabeth> + 37.5|jennifer> + 37.5|margaret> + 37.5|donna> + 25|mary> + 25|linda> + 25|barbara> + 25|nancy> + 25|karen> + 25|betty> + 25|helen> + 25|ruth> + 25|kimberly> + 25|shirley> + 25|melissa> + 12.5|patricia> + 12.5|maria> + 12.5|susan> + 12.5|dorothy> + 12.5|sandra> + 12.5|michelle> + 12.5|sarah> + 12.5|deborah> + 12.5|angela>
And this structure of course is not specific to faces. Any time you have stored features for a list of objects, you can input a subset of features and guess/predict which object it might be. For example, if you see the head of an elephant you can pretty confidently predict an entire elephant. Or parts of a bike or car or etc, predicting the whole object.

predicting a cat vs dog based on their noises

So, a toy one today, but it is easy to extend the idea to more interesting examples. The idea is, given some noises predict if it is a cat or a dog at the door. Let's say a cat can miaow, purr or scratch at the door, and a dog can pant, sniff or scratch at the door. That's easy enough to learn:
sa: dump
----------------------------------------
|context> => |context: animal sounds>

sounds-it-makes |cat> => |purring> + |miaowing> + |scratching at the door>
sounds-it-makes |dog> => |panting> + |sniffing> + |scratching at the door>
----------------------------------------
Now input some sounds and make a prediction:
-- from scratching predict dog and cat equally:
sa: normalize similar-input[sounds-it-makes] |scratching at the door>
0.5|cat> + 0.5|dog>

-- scratching and sniffing, so predict a dog is more likely:
sa: normalize similar-input[sounds-it-makes] (|scratching at the door> + |sniffing>)
0.667|dog> + 0.333|cat>
Simple example, but yeah it works, and is trivial to extend to larger examples.

Next, extend our predictions. Given a noise, predict what other noises may follow:
-- we hear panting, so predict other dog noises:
sa: sounds-it-makes similar-input[sounds-it-makes] |panting>
0.333|panting> + 0.333|sniffing> + 0.333|scratching at the door>

-- we hear purring, so predict other cat noises:
sa: sounds-it-makes similar-input[sounds-it-makes] |purring>
0.333|purring> + 0.333|miaowing> + 0.333|scratching at the door>

-- we hear scratching, so predict both cat and dog noises:
sa: sounds-it-makes similar-input[sounds-it-makes] |scratching at the door>
0.333|purring> + 0.333|miaowing> + 0.667|scratching at the door> + 0.333|panting> + 0.333|sniffing>
So it all works as you would expect and hope. And again we are at a point that my notation can encode an example, but we need a way to automate it. The CYC route of having humans input it all is not practical for my project!

Now, what if you object to concepts being represented by single kets? What if you want your concepts to be more robust to noise, and represented by SDR's (Sparse Distributed Representations, ie, superpositions with all coefficients equal to 1)? Well, with a little more work we can reproduce the above example using SDR's.

Build up some knowledge:
-- define our context:
  context animal sound SDR's

-- encode our concepts to random 5 bits on out of 100 SDR's:
-- 5/100 are themselves randomly chosen. Other values should work fine too.
  full |range> => range(|1>,|100>)
  encode |purring> => pick[5] full |range>
  encode |miaowing> => pick[5] full |range>
  encode |scratching at the door> => pick[5] full |range>
  encode |panting> => pick[5] full |range>
  encode |sniffing> => pick[5] full |range>

-- generate cat and dog noise SDR's by taking the union of the concept SDR's:
  sounds-it-makes |cat> => union[encode] (|purring> + |miaowing> + |scratching at the door>)
  sounds-it-makes |dog> => union[encode] (|panting> + |sniffing> + |scratching at the door>)
After loading that into the console we have:
sa: dump
----------------------------------------
|context> => |context: animal sound SDR's>

full |range> => |1> + |2> + |3> + |4> + |5> + |6> + |7> + |8> + |9> + |10> + |11> + |12> + |13> + |14> + |15> + |16> + |17> + |18> + |19> + |20> + |21> + |22> + |23> + |24> + |25> + |26> + |27> + |28> + |29> + |30> + |31> + |32> + |33> + |34> + |35> + |36> + |37> + |38> + |39> + |40> + |41> + |42> + |43> + |44> + |45> + |46> + |47> + |48> + |49> + |50> + |51> + |52> + |53> + |54> + |55> + |56> + |57> + |58> + |59> + |60> + |61> + |62> + |63> + |64> + |65> + |66> + |67> + |68> + |69> + |70> + |71> + |72> + |73> + |74> + |75> + |76> + |77> + |78> + |79> + |80> + |81> + |82> + |83> + |84> + |85> + |86> + |87> + |88> + |89> + |90> + |91> + |92> + |93> + |94> + |95> + |96> + |97> + |98> + |99> + |100>

encode |purring> => |43> + |75> + |38> + |20> + |26>
encode |miaowing> => |26> + |14> + |42> + |90> + |73>
encode |scratching at the door> => |97> + |89> + |58> + |65> + |82>
encode |panting> => |32> + |25> + |83> + |99> + |50>
encode |sniffing> => |20> + |8> + |4> + |24> + |84>

sounds-it-makes |cat> => |43> + |75> + |38> + |20> + |26> + |14> + |42> + |90> + |73> + |97> + |89> + |58> + |65> + |82>
sounds-it-makes |dog> => |32> + |25> + |83> + |99> + |50> + |20> + |8> + |4> + |24> + |84> + |97> + |89> + |58> + |65> + |82>
----------------------------------------
Let's now redo the predictions, this time using the SDR representation:
-- from scratching predict dog and cat equally:
sa: normalize similar-input[sounds-it-makes] encode |scratching at the door>
0.517|cat> + 0.483|dog>

-- scratching and sniffing, so predict a dog is more likely:
sa: normalize similar-input[sounds-it-makes] encode (|scratching at the door> + |sniffing>)
0.609|dog> + 0.391|cat>
Noting that the SDR's are noisier than the clean ket version, and so the probabilities are not as perfect. But we expect this from a brain, to not be perfect.

Now redo the predict related sounds example:
sa: similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |panting>
0.333|scratching at the door> + 0.333|panting> + 0.333|sniffing> + 0.067|purring>

sa: similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |purring>
0.353|scratching at the door> + 0.309|purring> + 0.298|miaowing> + 0.115|sniffing> + 0.056|panting>

sa: similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |scratching at the door>
0.345|scratching at the door> + 0.212|purring> + 0.202|sniffing> + 0.179|miaowing> + 0.167|panting>
So it pretty much works, just a bit noisier. But we can filter out the noise using drop-below[t], just like a brain filters out noise with thresholds. And wrap it up into a natural language like operator:
I-predict-from |*> #=> list-to-words drop-below[0.15] (similar-input[encode] sounds-it-makes similar-input[sounds-it-makes] encode |_self> + -|_self>)

sa: I-predict-from |panting>
|scratching at the door and sniffing>

sa: I-predict-from |purring>
|scratching at the door and miaowing>

sa: I-predict-from |scratching at the door>
|purring, sniffing, miaowing and panting>
That is kind of pretty. It reads like natural language. But really we are a long, long, long way from full natural language capabilities and of course full AGI. But I take our current results as a big hint that we are at least on the right path. Heh, we just need to scale it up a billion or trillion fold!

And I still think it is cool that notation that originated from quantum mechanics seems to be a good fit for describing what is going on in brains. And there seems to be hints of deeper overlap between the two systems. Just hints though. Let's try to list some of them:

1) the shared notation of operators, kets and superpositions.
 
2) Wavefunction collapse and measurement in my notation:
some-measurement |some object/system> !=> normalize weighted-pick-elt (P1|state 1> + P2|state 2> + ... + Pn|state n>)
3) Path integrals. A particle takes all possible pathways through space-time from its' starting point to its ending point, vs a spike train in a brain takes all possible brain pathways from the starting neuron to the end point neuron. For this reason maybe call brains "brain-space".

4) Quantum foam. At the deepest level space-time is full of noisy virtual particles, likewise, at the deepest levels the brain is deeply noisy too.

But for now don't take these too seriously. They are just interesting hints of similarities. The above is hinting that there might be some similarity between particles in space-time and neural spike trains in brain-space. OK. But what is the brain-space equivalent of mass, charge, spin, particle type, momentum, energy etc? So it would be extremely bold to suggest space time is a giant neural network, but it is more plausible that we can treat spike trains as some kind of quasi-particle. And has particle-like interactions with other spike trains as it propagates through a brain.