some built in functions
First up in phase 2, some functions built into our ket and superposition classes. There are quite a few of these, but in this post I think I will only mention the most useful ones. (note that SP is just some superposition)
-- randomly select an element from SP
-- eventually I want a weighted pick-elt too.
-- normalize so sum of coeffs = 1
-- (this can be used to map a frequency list to a list of probabilities)
-- normalize so sum of coeffs = t
-- rescale coeffs so coeff of max element = 1
-- rescale coeffs so coeff of max element = t
--returns number of elements in SP in |number: x> format
-- returns sum of coeffs of the elements in SP in |number: x> format
-- returns the product of coeffs of the elements in SP in |number: x> format
-- drop elements from SP with coeff <= 0.
-- NB: in our model coeffs are almost always >= 0
-- drop elements from SP with coeff below t
-- drop elements from SP with coeff above t
-- keep elements with index in range [a,b]
-- NB: index starts at 1, not 0
-- return element with index k
-- delete k'th element from the superposition.
-- reverse the SP
-- shuffle the SP
-- sort superposition by the coeffs of the kets
-- this one is very useful!
-- especially in combination with op-self operators
-- sort using a natural sort of lowercase labels of the kets
-- NB: sometimes natural sort bugs out, and I have to manually
-- swap the code back to standard lowercase sort.
-- eg, the binary tree example with kets such as |00> and |0010> and so on.
-- return the first ket found with the max coeff
-- return the first ket found with the min coeff
-- return the kets with the max coeff
-- return the kets with the min coeff
-- return the max coeff in the SP in |number: x> format
-- return the min coeff in the SP in |number: x> format
-- mulitply all coeffs by t
-- add noise to the SP in range [0,t]
-- add noise to the SP in range [0,t*max_coeff]
-- returns the difference between the largest coeff and the second largest coeff.
-- in 3| > format.
-- returns |no> if SP is the identity element |>
-- otherwise returns |yes>
I guess that is about it! Note there is a longer, more detailed version of the above here, which shows the mapping between the underlying python and the BKO (though it is incomplete).
BTW, I deliberately left out these two, as I will describe them in phase 3 of the write-up:
previous: announcing phase 2 function operators
next: introducing sigmoids
by Garry Morrison
email: garry -at- semantic-db.org