Probability of false positive when classifying a set of vectors

In @subutai’s Properties of Sparse Distributed Representations and their Application to Hierarchical Temporal Memory, there is this formula I’m trying to better understand:

This is supposed to calculate the probability of a false positive match of an incoming SDR from a set of SDRs.

From what I understand, it means that for each SDR in the set, calculate the overall capacity of the SDR and multiply by bits of error t, then multiply all those products?

Please excuse my ignorance of maths. :stuck_out_tongue:.

Ok, I figured this out with @subuai’s help.

is essentially a call to a previously defined formula (7):

So I must pass θ into that formula for each SDR in the set, and add their probabilities together to get a sum.

That math is too dense for me, in my current level of studies! I’m glad that clears it up for you! :wink: (One day, but right now I’m not understanding entirely)

Hopefully it will clear up in the next HTM School episode about classifying vectors and SDR unions. I’ll post it when I get it uploaded (tomorrow hopefully?).

1 Like

I had a question a month ago … the math didn’t seem to work for me !!! for some reason .
Here is copy of the email :


(code and paper below)

Trying to do the SDR-Union calculations… (sections G. and H. of the paper)
But there is something fishy, when i try to “unionize” more than 50 vectors the number of 1s according to the formulas goes
above 50% and as consequence it tries to calculate nCr(729,1261) i.e. in N choose R , R > N !

What I’m doing wrong ?!

In [122]: fp_union(n=2000,w=40,b=10,M=20)
p1> 0.332392028245
wx> 664.78405649
n,r: 664, 10
n,r: 1336, 654
n,r: 2000, 664
Out[122]: 4.7829847875715666e-129

In [123]: fp_union(n=2000,w=40,b=10,M=50)
p1> 0.635830319913
wx> 1271.66063983
n,r: 1271, 10
n,r: 729, 1261
AssertionError: nCr : n < r !
from __future__ import division
import operator as op

def nCr(n,r):
    print "n,r: %s, %s" % (n,r)
    assert n >= r, "nCr : n < r !"
    r = min(r,n-r)
    if r == 0 : return 1
    numerator = reduce(op.mul, xrange(n,n-r,-1))
    denominator = reduce(op.mul, xrange(1, r+1) )
    return numerator//denominator

#count of vectors with w-bits ON that have b-bits overlap
def overlap_set(n,w,b): #nCr(n,w) are all possible combinations
    return nCr(w,b) * nCr(n-w , w-b)

#inexact match : false positive overlap set
# probability of random vector to be false positive
def fp_oset(n,w,b): return overlap_set(n,w,b) / nCr(n,w)

#exact mathch : probability of bit being 0 (zero) after M additions
def fp_union_p0(n,w,M) :
    p0 = ( 1 - (w/float(n)) )**M
    print "p1> %s" % (1 - p0)
    return p0

#inexact match: M number of stored patterns
def fp_union(n,w,b,M):
    wx = n * (1 - fp_union_p0(n,w,M))
    print "wx> %s" % wx
#    wx = w
    return fp_oset(n, int(wx), b)

It is working for me now. See all my SDR operations in JavaScript here:

you will have this as a web page, right ?

@mraptor See: