In [2]:
from sympy import *
init_printing()
from IPython.display import display

%matplotlib inline

import matplotlib.pyplot as plt

Equation for Neuron Paper

  A dendritic segment can robustly classify a pattern by subsampling a small number of cells from a larger population.  Assuming a random distribution of patterns, the exact probability of a false match is given by the following equation:

In [3]:
oxp = Symbol("Omega_x'")
b = Symbol("b")
n = Symbol("n")
theta = Symbol("theta")
s = Symbol("s")
a = Symbol("a")

subsampledOmega = (binomial(s, b) * binomial(n - s, a - b)) / binomial(n, a)
subsampledFpF = Sum(subsampledOmega, (b, theta, s))
subsampledOmegaSlow = (binomial(s, b) * binomial(n - s, a - b)) 
subsampledFpFSlow = Sum(subsampledOmegaSlow, (b, theta, s))/ binomial(n, a)

display(subsampledFpF)
display(subsampledFpFSlow)


$$\sum_{b=\theta}^{s} \frac{{\binom{s}{b}}}{{\binom{n}{a}}} {\binom{n - s}{a - b}}$$
$$\frac{1}{{\binom{n}{a}}} \sum_{b=\theta}^{s} {\binom{s}{b}} {\binom{n - s}{a - b}}$$

where n refers to the size of the population of cells, a is the number of active cells at any instance in time, s is the number of actual synapses on a dendritic segment, and θ is the threshold for NMDA spikes. Following (Ahmad & Hawkins, 2015), the numerator counts the number of possible ways θ or more cells can match a fixed set of s synapses. The denominator counts the number of ways a cells out of n can be active.

Example usage


In [4]:
display("n=10000, a=64, s=24, theta=12", subsampledFpF.subs(s,24).subs(n, 10000).subs(a, 64).subs(theta, 12).evalf())


'n=10000, a=64, s=24, theta=12'
$$0$$

In [5]:
display("n=10000, a=300, s=24, theta=12", subsampledFpFSlow.subs(theta, 12).subs(s, 24).subs(n, 10000).subs(a, 300).evalf())


'n=10000, a=300, s=24, theta=12'
$$8.37584522709849 \cdot 10^{-13}$$

In [6]:
display("n=2000, a=40, s=20, theta=10", subsampledFpF.subs(theta, 15).subs(s, 20).subs(n, 2000).subs(a, 40).evalf(100))


'n=2000, a=40, s=20, theta=10'
$$0.00000000000000000000002471923309430865822098460766581817893796333000093320612443608951048768022360840257449483136714689953$$

Table 1B


In [7]:
T1B = subsampledFpFSlow.subs(n, 100000).subs(a, 2000).subs(theta,s).evalf()
print "n=100000, a=2000, theta=s"
display("s=6",T1B.subs(s,6).evalf())
display("s=8",T1B.subs(s,8).evalf())
display("s=10",T1B.subs(s,10).evalf())


n=100000, a=2000, theta=s
's=6'
$$6.35308872941916 \cdot 10^{-11}$$
's=8'
$$2.52507239284961 \cdot 10^{-14}$$
's=10'
$$1.00163216178113 \cdot 10^{-17}$$

Table 1C


In [8]:
T1C = subsampledFpFSlow.subs(n, 100000).subs(a, 2000).subs(s,2*theta).evalf()
print "n=10000, a=300, s=2*theta"
display("theta=6",T1C.subs(theta,6).evalf())
display("theta=8",T1C.subs(theta,8).evalf())
display("theta=10",T1C.subs(theta,10).evalf())
display("theta=12",T1C.subs(theta,12).evalf())


n=10000, a=300, s=2*theta
'theta=6'
$$5.29386836275369 \cdot 10^{-8}$$
'theta=8'
$$2.81724528327272 \cdot 10^{-10}$$
'theta=10'
$$1.5419276725872 \cdot 10^{-12}$$
'theta=12'
$$8.58694100276592 \cdot 10^{-15}$$

Table 1D


In [9]:
m = Symbol("m")
T1D = subsampledFpF.subs(n, 100000).subs(a, 2000).subs(s,2*m*theta).evalf()
print "n=100000, a=2000, s=2*m*theta"
display("theta=10, m=2",T1D.subs(theta,10).subs(m,2).evalf())
display("theta=10, m=4",T1D.subs(theta,10).subs(m,4).evalf())
display("theta=10, m=6",T1D.subs(theta,10).subs(m,6).evalf())
display("theta=20, m=6",T1D.subs(theta,20).subs(m,6).evalf())


n=100000, a=2000, s=2*m*theta
'theta=10, m=2'
$$4.91541864813209 \cdot 10^{-9}$$
'theta=10, m=4'
$$4.62568448037595 \cdot 10^{-6}$$
'theta=10, m=6'
$$0.000158799793094937$$
'theta=20, m=6'
$$1.07990763941591 \cdot 10^{-7}$$

Charts for SDR Paper

  The following sections calculates the numbers for some of the SDR paper charts.


Importance of large n


In [10]:
eq1 = subsampledFpFSlow.subs(s, 64).subs(theta, 12)
print "a=64 cells active, s=16 synapses on segment, dendritic threshold is theta=8\n"
errorList = []
nList = []
for n0 in range(300,20100,200):
    error = eq1.subs(n, n0).subs(a,64).evalf()
    errorList += [error]
    nList += [n0]
    print "population n = %5d, sparsity = %5.2f%%, probability of false match = "%(n0, 64/n0), error
    
print errorList
print nList


a=64 cells active, s=16 synapses on segment, dendritic threshold is theta=8

population n =   300, sparsity =  0.00%, probability of false match =  0.767798046805888
population n =   500, sparsity =  0.00%, probability of false match =  0.0960845416487165
population n =   700, sparsity =  0.00%, probability of false match =  0.00881793984023789
population n =   900, sparsity =  0.00%, probability of false match =  0.00104201059477680
population n =  1100, sparsity =  0.00%, probability of false match =  0.000161866998734267
population n =  1300, sparsity =  0.00%, probability of false match =  3.16121753895779e-5
population n =  1500, sparsity =  0.00%, probability of false match =  7.42838135168482e-6
population n =  1700, sparsity =  0.00%, probability of false match =  2.02810556367455e-6
population n =  1900, sparsity =  0.00%, probability of false match =  6.26296994067198e-7
population n =  2100, sparsity =  0.00%, probability of false match =  2.14288245865589e-7
population n =  2300, sparsity =  0.00%, probability of false match =  7.99418222318950e-8
population n =  2500, sparsity =  0.00%, probability of false match =  3.21077808048928e-8
population n =  2700, sparsity =  0.00%, probability of false match =  1.37438883181648e-8
population n =  2900, sparsity =  0.00%, probability of false match =  6.21879891409450e-9
population n =  3100, sparsity =  0.00%, probability of false match =  2.95443192395266e-9
population n =  3300, sparsity =  0.00%, probability of false match =  1.46548703909345e-9
population n =  3500, sparsity =  0.00%, probability of false match =  7.55426623928377e-10
population n =  3700, sparsity =  0.00%, probability of false match =  4.03069042524778e-10
population n =  3900, sparsity =  0.00%, probability of false match =  2.21855613504858e-10
population n =  4100, sparsity =  0.00%, probability of false match =  1.25602427254846e-10
population n =  4300, sparsity =  0.00%, probability of false match =  7.29565898352752e-11
population n =  4500, sparsity =  0.00%, probability of false match =  4.33823270726987e-11
population n =  4700, sparsity =  0.00%, probability of false match =  2.63574676030204e-11
population n =  4900, sparsity =  0.00%, probability of false match =  1.63341677848632e-11
population n =  5100, sparsity =  0.00%, probability of false match =  1.03094878512466e-11
population n =  5300, sparsity =  0.00%, probability of false match =  6.61820425636368e-12
population n =  5500, sparsity =  0.00%, probability of false match =  4.31602894863397e-12
population n =  5700, sparsity =  0.00%, probability of false match =  2.85628272660169e-12
population n =  5900, sparsity =  0.00%, probability of false match =  1.91632278470408e-12
population n =  6100, sparsity =  0.00%, probability of false match =  1.30228251757813e-12
population n =  6300, sparsity =  0.00%, probability of false match =  8.95704526501288e-13
population n =  6500, sparsity =  0.00%, probability of false match =  6.23063767783764e-13
population n =  6700, sparsity =  0.00%, probability of false match =  4.38047430918503e-13
population n =  6900, sparsity =  0.00%, probability of false match =  3.11076993767398e-13
population n =  7100, sparsity =  0.00%, probability of false match =  2.23013796374613e-13
population n =  7300, sparsity =  0.00%, probability of false match =  1.61321052161476e-13
population n =  7500, sparsity =  0.00%, probability of false match =  1.17690561046501e-13
population n =  7700, sparsity =  0.00%, probability of false match =  8.65555486648568e-14
population n =  7900, sparsity =  0.00%, probability of false match =  6.41470046810705e-14
population n =  8100, sparsity =  0.00%, probability of false match =  4.78877290083649e-14
population n =  8300, sparsity =  0.00%, probability of false match =  3.59988148092467e-14
population n =  8500, sparsity =  0.00%, probability of false match =  2.72413367559495e-14
population n =  8700, sparsity =  0.00%, probability of false match =  2.07450519186865e-14
population n =  8900, sparsity =  0.00%, probability of false match =  1.58936937437398e-14
population n =  9100, sparsity =  0.00%, probability of false match =  1.22474470259293e-14
population n =  9300, sparsity =  0.00%, probability of false match =  9.49008634350598e-15
population n =  9500, sparsity =  0.00%, probability of false match =  7.39262555848706e-15
population n =  9700, sparsity =  0.00%, probability of false match =  5.78811819582042e-15
population n =  9900, sparsity =  0.00%, probability of false match =  4.55405220189980e-15
population n = 10100, sparsity =  0.00%, probability of false match =  3.59995870603115e-15
population n = 10300, sparsity =  0.00%, probability of false match =  2.85862824712372e-15
population n = 10500, sparsity =  0.00%, probability of false match =  2.27984148947650e-15
population n = 10700, sparsity =  0.00%, probability of false match =  1.82586511021711e-15
population n = 10900, sparsity =  0.00%, probability of false match =  1.46819534023413e-15
population n = 11100, sparsity =  0.00%, probability of false match =  1.18518918830356e-15
population n = 11300, sparsity =  0.00%, probability of false match =  9.60331248430696e-16
population n = 11500, sparsity =  0.00%, probability of false match =  7.80958371258306e-16
population n = 11700, sparsity =  0.00%, probability of false match =  6.37316119269338e-16
population n = 11900, sparsity =  0.00%, probability of false match =  5.21857011831390e-16
population n = 12100, sparsity =  0.00%, probability of false match =  4.28715944127415e-16
population n = 12300, sparsity =  0.00%, probability of false match =  3.53316120669355e-16
population n = 12500, sparsity =  0.00%, probability of false match =  2.92071624826489e-16
population n = 12700, sparsity =  0.00%, probability of false match =  2.42161894566693e-16
population n = 12900, sparsity =  0.00%, probability of false match =  2.01359959726941e-16
population n = 13100, sparsity =  0.00%, probability of false match =  1.67901061328122e-16
population n = 13300, sparsity =  0.00%, probability of false match =  1.40381739546325e-16
population n = 13500, sparsity =  0.00%, probability of false match =  1.17682010751169e-16
population n = 13700, sparsity =  0.00%, probability of false match =  9.89051152843804e-17
population n = 13900, sparsity =  0.00%, probability of false match =  8.33306913245833e-17
population n = 14100, sparsity =  0.00%, probability of false match =  7.03782486292717e-17
population n = 14300, sparsity =  0.00%, probability of false match =  5.95785743686907e-17
population n = 14500, sparsity =  0.00%, probability of false match =  5.05512704847369e-17
population n = 14700, sparsity =  0.00%, probability of false match =  4.29870479976394e-17
population n = 14900, sparsity =  0.00%, probability of false match =  3.66337249063553e-17
population n = 15100, sparsity =  0.00%, probability of false match =  3.12851175067647e-17
population n = 15300, sparsity =  0.00%, probability of false match =  2.67721997530410e-17
population n = 15500, sparsity =  0.00%, probability of false match =  2.29560462498643e-17
population n = 15700, sparsity =  0.00%, probability of false match =  1.97221823764714e-17
population n = 15900, sparsity =  0.00%, probability of false match =  1.69760479483278e-17
population n = 16100, sparsity =  0.00%, probability of false match =  1.46393447333667e-17
population n = 16300, sparsity =  0.00%, probability of false match =  1.26470875739574e-17
population n = 16500, sparsity =  0.00%, probability of false match =  1.09452172272728e-17
population n = 16700, sparsity =  0.00%, probability of false match =  9.48866290051899e-18
population n = 16900, sparsity =  0.00%, probability of false match =  8.23976577817741e-18
population n = 17100, sparsity =  0.00%, probability of false match =  7.16699310476475e-18
population n = 17300, sparsity =  0.00%, probability of false match =  6.24388673637030e-18
population n = 17500, sparsity =  0.00%, probability of false match =  5.44820137970605e-18
population n = 17700, sparsity =  0.00%, probability of false match =  4.76119666953519e-18
population n = 17900, sparsity =  0.00%, probability of false match =  4.16705431178299e-18
population n = 18100, sparsity =  0.00%, probability of false match =  3.65239714098025e-18
population n = 18300, sparsity =  0.00%, probability of false match =  3.20589141787563e-18
population n = 18500, sparsity =  0.00%, probability of false match =  2.81791726811520e-18
population n = 18700, sparsity =  0.00%, probability of false match =  2.48029502476245e-18
population n = 18900, sparsity =  0.00%, probability of false match =  2.18605753401716e-18
population n = 19100, sparsity =  0.00%, probability of false match =  1.92926033086935e-18
population n = 19300, sparsity =  0.00%, probability of false match =  1.70482308095028e-18
population n = 19500, sparsity =  0.00%, probability of false match =  1.50839688859563e-18
population n = 19700, sparsity =  0.00%, probability of false match =  1.33625304613249e-18
population n = 19900, sparsity =  0.00%, probability of false match =  1.18518959085345e-18
[0.767798046805888, 0.0960845416487165, 0.00881793984023789, 0.00104201059477680, 0.000161866998734267, 3.16121753895779e-5, 7.42838135168482e-6, 2.02810556367455e-6, 6.26296994067198e-7, 2.14288245865589e-7, 7.99418222318950e-8, 3.21077808048928e-8, 1.37438883181648e-8, 6.21879891409450e-9, 2.95443192395266e-9, 1.46548703909345e-9, 7.55426623928377e-10, 4.03069042524778e-10, 2.21855613504858e-10, 1.25602427254846e-10, 7.29565898352752e-11, 4.33823270726987e-11, 2.63574676030204e-11, 1.63341677848632e-11, 1.03094878512466e-11, 6.61820425636368e-12, 4.31602894863397e-12, 2.85628272660169e-12, 1.91632278470408e-12, 1.30228251757813e-12, 8.95704526501288e-13, 6.23063767783764e-13, 4.38047430918503e-13, 3.11076993767398e-13, 2.23013796374613e-13, 1.61321052161476e-13, 1.17690561046501e-13, 8.65555486648568e-14, 6.41470046810705e-14, 4.78877290083649e-14, 3.59988148092467e-14, 2.72413367559495e-14, 2.07450519186865e-14, 1.58936937437398e-14, 1.22474470259293e-14, 9.49008634350598e-15, 7.39262555848706e-15, 5.78811819582042e-15, 4.55405220189980e-15, 3.59995870603115e-15, 2.85862824712372e-15, 2.27984148947650e-15, 1.82586511021711e-15, 1.46819534023413e-15, 1.18518918830356e-15, 9.60331248430696e-16, 7.80958371258306e-16, 6.37316119269338e-16, 5.21857011831390e-16, 4.28715944127415e-16, 3.53316120669355e-16, 2.92071624826489e-16, 2.42161894566693e-16, 2.01359959726941e-16, 1.67901061328122e-16, 1.40381739546325e-16, 1.17682010751169e-16, 9.89051152843804e-17, 8.33306913245833e-17, 7.03782486292717e-17, 5.95785743686907e-17, 5.05512704847369e-17, 4.29870479976394e-17, 3.66337249063553e-17, 3.12851175067647e-17, 2.67721997530410e-17, 2.29560462498643e-17, 1.97221823764714e-17, 1.69760479483278e-17, 1.46393447333667e-17, 1.26470875739574e-17, 1.09452172272728e-17, 9.48866290051899e-18, 8.23976577817741e-18, 7.16699310476475e-18, 6.24388673637030e-18, 5.44820137970605e-18, 4.76119666953519e-18, 4.16705431178299e-18, 3.65239714098025e-18, 3.20589141787563e-18, 2.81791726811520e-18, 2.48029502476245e-18, 2.18605753401716e-18, 1.92926033086935e-18, 1.70482308095028e-18, 1.50839688859563e-18, 1.33625304613249e-18, 1.18518959085345e-18]
[300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500, 2700, 2900, 3100, 3300, 3500, 3700, 3900, 4100, 4300, 4500, 4700, 4900, 5100, 5300, 5500, 5700, 5900, 6100, 6300, 6500, 6700, 6900, 7100, 7300, 7500, 7700, 7900, 8100, 8300, 8500, 8700, 8900, 9100, 9300, 9500, 9700, 9900, 10100, 10300, 10500, 10700, 10900, 11100, 11300, 11500, 11700, 11900, 12100, 12300, 12500, 12700, 12900, 13100, 13300, 13500, 13700, 13900, 14100, 14300, 14500, 14700, 14900, 15100, 15300, 15500, 15700, 15900, 16100, 16300, 16500, 16700, 16900, 17100, 17300, 17500, 17700, 17900, 18100, 18300, 18500, 18700, 18900, 19100, 19300, 19500, 19700, 19900]

Small sparsity is insufficient


In [11]:
print ("2% sparsity with n=400")
print subsampledFpFSlow.subs(s, 4).subs(a, 8).subs(theta, 2).subs(n,400).evalf()
print ("2% sparsity with n=4000")
print subsampledFpFSlow.subs(s, 4).subs(a, 400).subs(theta, 2).subs(n,4000).evalf()


2% sparsity with n=400
0.00206314616966578
2% sparsity with n=4000
0.0522148720308419

A small subsample can be very reliable (but not too small)


In [12]:
eq2 = subsampledFpFSlow.subs(n, 10000).subs(a, 300)
print "a=200 cells active out of population of n=10000 cells\n"
errorList = []
sList = []
for s0 in range(2,31,1):
    print "synapses s = %3d, theta = s/2 = %3d, probability of false match = "%(s0,s0/2), eq2.subs(s, s0).subs(theta,s0/2).evalf() 
    errorList += [eq2.subs(s, s0).subs(theta,s0/2).evalf()]
    sList += [s0]
    
print errorList
print sList


a=200 cells active out of population of n=10000 cells

synapses s =   2, theta = s/2 =   1, probability of false match =  0.0591029102910291
synapses s =   3, theta = s/2 =   1, probability of false match =  0.0873354694941389
synapses s =   4, theta = s/2 =   2, probability of false match =  0.00517101241148655
synapses s =   5, theta = s/2 =   2, probability of false match =  0.00844794620736664
synapses s =   6, theta = s/2 =   3, probability of false match =  0.000499865412306804
synapses s =   7, theta = s/2 =   3, probability of false match =  0.000855357919350205
synapses s =   8, theta = s/2 =   4, probability of false match =  5.05282906751424e-5
synapses s =   9, theta = s/2 =   4, probability of false match =  8.88044155296650e-5
synapses s =  10, theta = s/2 =   5, probability of false match =  5.23462085992797e-6
synapses s =  11, theta = s/2 =   5, probability of false match =  9.36152430040881e-6
synapses s =  12, theta = s/2 =   6, probability of false match =  5.50467708713271e-7
synapses s =  13, theta = s/2 =   6, probability of false match =  9.96590775459112e-7
synapses s =  14, theta = s/2 =   7, probability of false match =  5.84458284016591e-8
synapses s =  15, theta = s/2 =   7, probability of false match =  1.06781055245346e-7
synapses s =  16, theta = s/2 =   8, probability of false match =  6.24488987535941e-9
synapses s =  17, theta = s/2 =   8, probability of false match =  1.14900993578035e-8
synapses s =  18, theta = s/2 =   9, probability of false match =  6.70048689113995e-10
synapses s =  19, theta = s/2 =   9, probability of false match =  1.23977606153067e-9
synapses s =  20, theta = s/2 =  10, probability of false match =  7.20851539659221e-11
synapses s =  21, theta = s/2 =  10, probability of false match =  1.33990428897848e-10
synapses s =  22, theta = s/2 =  11, probability of false match =  7.76731651059463e-12
synapses s =  23, theta = s/2 =  11, probability of false match =  1.44929751014167e-11
synapses s =  24, theta = s/2 =  12, probability of false match =  8.37584522709849e-13
synapses s =  25, theta = s/2 =  12, probability of false match =  1.56790489972169e-12
synapses s =  26, theta = s/2 =  13, probability of false match =  9.03331595141546e-14
synapses s =  27, theta = s/2 =  13, probability of false match =  1.69568150423906e-13
synapses s =  28, theta = s/2 =  14, probability of false match =  9.73897092618566e-15
synapses s =  29, theta = s/2 =  14, probability of false match =  1.83255953842929e-14
synapses s =  30, theta = s/2 =  15, probability of false match =  1.04919182521237e-15
[0.0591029102910291, 0.0873354694941389, 0.00517101241148655, 0.00844794620736664, 0.000499865412306804, 0.000855357919350205, 5.05282906751424e-5, 8.88044155296650e-5, 5.23462085992797e-6, 9.36152430040881e-6, 5.50467708713271e-7, 9.96590775459112e-7, 5.84458284016591e-8, 1.06781055245346e-7, 6.24488987535941e-9, 1.14900993578035e-8, 6.70048689113995e-10, 1.23977606153067e-9, 7.20851539659221e-11, 1.33990428897848e-10, 7.76731651059463e-12, 1.44929751014167e-11, 8.37584522709849e-13, 1.56790489972169e-12, 9.03331595141546e-14, 1.69568150423906e-13, 9.73897092618566e-15, 1.83255953842929e-14, 1.04919182521237e-15]
[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]

Impact of noise on false negatives


In [13]:
b = Symbol("b")
v = Symbol("v")
theta = Symbol("theta")
s = Symbol("s")
a = Symbol("a")

overlapSetNoise = (binomial(s, b) * binomial(a - s, v - b)) / binomial(a, v)
noiseFN = Sum(overlapSetNoise, (b, s-theta+1, s))

In [14]:
eqn = noiseFN.subs(s, 30).subs(a, 128)
print "a=128 cells active with segment containing s=30 synapses (n doesn't matter here)\n"
for t in range(8,20,4):
    print "theta = ",t
    errorList = []
    noiseList = []
    noisePct = 0.05
    while noisePct <= 0.85:
        noise = int(round(noisePct*128,0))
        errorList += [eqn.subs(v, noise).subs(theta,t).evalf()]
        noiseList += [noise/128.0]
        noisePct += 0.05
    print errorList
    print noiseList


a=128 cells active with segment containing s=30 synapses (n doesn't matter here)

theta =  8
[0, 0, 0, 3.11341516283240e-16, 2.23243424464799e-12, 7.90168637530306e-10, 1.20695707971664e-7, 3.45576265561118e-6, 8.08202472708491e-5, 0.000735429456875121, 0.00464043435771348, 0.0268657157114204, 0.0896352007201254, 0.263952754229579, 0.508714577385333, 0.770861966941236]
[0.046875, 0.1015625, 0.1484375, 0.203125, 0.25, 0.296875, 0.3515625, 0.3984375, 0.453125, 0.5, 0.546875, 0.6015625, 0.6484375, 0.703125, 0.75, 0.796875]
theta =  12
[0, 0, 2.48810797387309e-15, 7.92695349343630e-10, 2.16302525195240e-7, 1.09248135880715e-5, 0.000314435369055385, 0.00279559866084888, 0.0198782675563797, 0.0716985160403564, 0.190430462690358, 0.426525969583828, 0.664766152465367, 0.880922510721824, 0.970339402698393, 0.996376835285247]
[0.046875, 0.1015625, 0.1484375, 0.203125, 0.25, 0.296875, 0.3515625, 0.3984375, 0.453125, 0.5, 0.546875, 0.6015625, 0.6484375, 0.703125, 0.75, 0.796875]
theta =  16
[0, 0, 2.65549705827547e-8, 1.97277260559420e-5, 0.000590078912236923, 0.00627504390204146, 0.0434711883681422, 0.139067254386793, 0.351117043857492, 0.582501773030327, 0.788076297517739, 0.933878292787173, 0.983735005386502, 0.998319255844748, 0.999889798557155, 0.999997748076386]
[0.046875, 0.1015625, 0.1484375, 0.203125, 0.25, 0.296875, 0.3515625, 0.3984375, 0.453125, 0.5, 0.546875, 0.6015625, 0.6484375, 0.703125, 0.75, 0.796875]

Impact of noise on first-order TMs trained on one sequence

We assume that false positives are impossible -- this is in fact not strictly true, but the number of segments is so low that it might as well be.


In [15]:
eqn = noiseFN
eqn = eqn.subs(s, 20).subs(a, 40).subs(c, 40)
for t in range(8, 20, 4):
    print "theta = ",t
    errorList = []
    jaccardSimilarityList = []
    noiseList = []
    noisePct = 0.00
    while noisePct <= 1:
        noise = int(round(noisePct*40,0))
        error = eqn.subs(v, noise).subs(theta,t).evalf()
        errorList.append(error)
        jaccardSimilarity = 1 - error
        jaccardSimilarityList.append(jaccardSimilarity)
        noiseList += [noise/40.0]
        noisePct += 0.05
    print errorList
    print jaccardSimilarityList
    print noiseList


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-15-fdbe6a54783c> in <module>()
      1 eqn = noiseFN
----> 2 eqn = eqn.subs(s, 20).subs(a, 40).subs(c, 40)
      3 for t in range(8, 20, 4):
      4     print "theta = ",t
      5     errorList = []

NameError: name 'c' is not defined

Charts for BAMI


In [16]:
w0 = 32
print "a=%d cells active, s=%d synapses on segment, dendritic threshold is s/2\n" % (w0,w0)
errorList = []
nList = []
for n0 in range(50,500,50):
    w0 = n0/2
    eq1 = subsampledFpFSlow.subs(s, w0).subs(theta, w0/2)
    error = eq1.subs(n, n0).subs(a,w0).evalf()
    errorList += [error]
    nList += [n0]
    print "population n = %5d, sparsity = %7.4f%%, probability of false match = "%(n0, float(w0)/n0), error
    
print errorList
print nList


a=32 cells active, s=32 synapses on segment, dendritic threshold is s/2

population n =    50, sparsity =  0.5000%, probability of false match =  0.713930783595416
population n =   100, sparsity =  0.5000%, probability of false match =  0.579192330580665
population n =   150, sparsity =  0.5000%, probability of false match =  0.627949560779490
population n =   200, sparsity =  0.5000%, probability of false match =  0.556207787852021
population n =   250, sparsity =  0.5000%, probability of false match =  0.599827556589778
population n =   300, sparsity =  0.5000%, probability of false match =  0.545950866779313
population n =   350, sparsity =  0.5000%, probability of false match =  0.584632630831763
population n =   400, sparsity =  0.5000%, probability of false match =  0.539819496834182
population n =   450, sparsity =  0.5000%, probability of false match =  0.574768441538204
[0.713930783595416, 0.579192330580665, 0.627949560779490, 0.556207787852021, 0.599827556589778, 0.545950866779313, 0.584632630831763, 0.539819496834182, 0.574768441538204]
[50, 100, 150, 200, 250, 300, 350, 400, 450]

Union Property Math

Here, we calculate the expected error rates for unions of various sizes, with varying dimensions and sparsities. This is used in plots for the Neuron paper.


In [17]:
oxd = Symbol("omega")
n = Symbol("n")
a = Symbol("a")
b = Symbol("b")
theta = Symbol("theta")
s = Symbol("s")
m = Symbol("m")
q = Symbol("q")

p = (1 - a/n) ** m
ss = Min(floor((1 - (1 - s/n)**m)*n), a)

expectedUnionOverlap =  binomial(((1 - p)*n), b) * binomial(((n - (1 - p)*n)), a - b) / binomial(n, a)
expectedUnionFP = Sum(expectedUnionOverlap, (b, theta, ss))

display(expectedUnionFP)


$$\sum_{b=\theta}^{\min\left(a, \lfloor{n \left(- \left(1 - \frac{s}{n}\right)^{m} + 1\right)}\rfloor\right)} \frac{1}{{\binom{n}{a}}} {\binom{n \left(- \left(- \frac{a}{n} + 1\right)^{m} + 1\right)}{b}} {\binom{- n \left(- \left(- \frac{a}{n} + 1\right)^{m} + 1\right) + n}{a - b}}$$

In [18]:
eq1 = expectedUnionFP.subs(a, 40).subs(n, 4000).subs(theta, 15).subs(s, 30)
display(eq1)

for num_patterns in range(100):
    eq2 = eq1.subs(m, num_patterns)
    #display(eq2)
    error_prob = eq2.evalf(100)
    print num_patterns, error_prob


$$\sum_{b=15}^{\min\left(40, \lfloor{- 4000 \left(\frac{397}{400}\right)^{m}}\rfloor + 4000\right)} \frac{1}{1218391930138619279558518940704582171559368245663254409399842941760054431871228116354726833248400} {\binom{4000 \left(\frac{99}{100}\right)^{m}}{- b + 40}} {\binom{- 4000 \left(\frac{99}{100}\right)^{m} + 4000}{b}}$$
0 0
1 0.000000000000000000001745032216871438090517748709430240184404544869372092932990501764967163185476624815904215229805420692
2 0.0000000000000002093468685928811801989717729017516091277687796544570405122615488775764198833250143098252085743081943
3 0.0000000000001091758776979344433495190028335131313256945573398716353241939392444505507255409008113375381478068025
4 0.000000000007575918762457399263916640767599584844271471997036011048438470323012907960591826464196106810238596218
5 0.0000000001814421512098364828902010548712515048686609396337277833566447515902789676799747568196961072283645763
6 0.000000002248520791277327492290796623999930059599315117596382321155353679106977615017740475810202854920301505
7 0.00000001779329137132590681767775746815254927118928197200267985021165612640886614001871820394749448092383756
8 0.0000001017201482488728819151737506974190201700891964811656321916877721839928071431788182545666671963198185
9 0.0000004544626711472886148782943170010378460105169655813186634988460443436161509812037269859880281873716257
10 0.000001673545205416077459724790345759409758555860083672651394312442782337716385262891408052080307872762011
11 0.000005274634381890824649967731453786697075580030725623346216696757615231015528962224029456798627635286104
12 0.00001462791199478933856746051940481505112034594542712133079374880098530818256811892331207461912043358368
13 0.00003644979576418442097730393509143113446076968166508018205759159074578781720107325971584123538102030605
14 0.00008294107081500744874715114375028943571885033637485231209595101339269906442780758764550203782350796674
15 0.0001745701338736711885975171319200187654810183764638769182399278538915889494881529886896615133443282304
16 0.0003433768379824176943612680133133248469921353393738076151602423309472573544939086725543208776043038801
17 0.0006365407870000748797865803930872278872799954552777804103952419844628528741500949482368939864597206811
18 0.001119844416140449358299231800844055558202129038822569334973665690811165740170523679043437409612731079
19 0.001880589932142477141139829155520709964107073600076870829583643475233179857435025035669660077977883288
20 0.003029516466704932995869284049555306241680409015559002643762774910238281926314100999784074530679865040
21 0.004701315022275674434827093613270219189440105084064340308316476402237748050567994294891107880340534753
22 0.007053448113907231068129722312763114182905519715788955001662133948945080140966459086644688604308348714
23 0.01026313329712844090376873239544988462442396408799465192075410874713792107070085924575382566497596026
24 0.01452252404418872384635156536920806209226258673667343530521979074654362702316663747273265559965985879
25 0.02003229487143450552807350008694978229905090583843567119834226766230788892191024835219285847048641993
26 0.02699398926227861796362222287395173577731546137357835818779537047858009178890456816425422323353628860
27 0.03560160246339447789921941579335705799323130239575454325807580112481064701853903602736196311323876529
28 0.04603293663272091757741901569331072811854673259582932550477183274585855827236602007762478479240060083
29 0.05844127978667884439913199409065146564937159941719975460908440338646401658633179450049951565867057525
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-18-43e8f497ac7a> in <module>()
      5     eq2 = eq1.subs(m, num_patterns)
      6     #display(eq2)
----> 7     error_prob = eq2.evalf(100)
      8     print num_patterns, error_prob

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/evalf.pyc in evalf(self, n, subs, maxn, chop, strict, quad, verbose)
   1383             options['quad'] = quad
   1384         try:
-> 1385             result = evalf(self, prec + 4, options)
   1386         except NotImplementedError:
   1387             # Fall back to the ordinary evalf

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/evalf.pyc in evalf(x, prec, options)
   1276     try:
   1277         rf = evalf_table[x.func]
-> 1278         r = rf(x, prec, options)
   1279     except KeyError:
   1280         try:

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/evalf.pyc in evalf_sum(expr, prec, options)
   1174             m = n = 2**i * prec
   1175             s, err = expr.euler_maclaurin(m=m, n=n, eps=eps,
-> 1176                 eval_integral=False)
   1177             err = err.evalf()
   1178             if err <= eps:

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/concrete/summations.pyc in euler_maclaurin(self, m, n, eps, eval_integral)
    597                     if abs(term.evalf(3)) < eps and term != 0:
    598                         return s, abs(term)
--> 599                     s += term
    600             if b - a + 1 == m:
    601                 return s, S.Zero

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/decorators.pyc in __sympifyit_wrapper(a, b)
     75                 if not hasattr(b, '_op_priority'):
     76                     b = sympify(b, strict=True)
---> 77                 return func(a, b)
     78             except SympifyError:
     79                 return retval

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/numbers.pyc in __add__(self, other)
   1372     def __add__(self, other):
   1373         if isinstance(other, Rational):
-> 1374             return Rational(self.p*other.q + self.q*other.p, self.q*other.q)
   1375         elif isinstance(other, Float):
   1376             return other + self

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/cache.pyc in wrapper(*args, **kwargs)
     91             def wrapper(*args, **kwargs):
     92                 try:
---> 93                     retval = cfunc(*args, **kwargs)
     94                 except TypeError:
     95                     retval = func(*args, **kwargs)

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/compatibility.pyc in wrapper(*args, **kwds)
    897                         stats[HITS] += 1
    898                         return result
--> 899                 result = user_function(*args, **kwds)
    900                 with lock:
    901                     root, = nonlocal_root

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/numbers.pyc in __new__(cls, p, q)
   1287             q = -q
   1288             p = -p
-> 1289         n = igcd(abs(p), q)
   1290         if n > 1:
   1291             p //= n

/Users/mschwarzer/Library/Python/2.7/lib/python/site-packages/sympy/core/numbers.pyc in igcd(*args)
    168 
    169                 while b:
--> 170                     a, b = b, a % b
    171             else:
    172                 a = abs(a or b)

KeyboardInterrupt: 

In [19]:
eq1 = p.subs(a, 40).subs(n, 4000)
for num_patterns in range(100):
    expected_distinct = eq1.subs(m, num_patterns).evalf(10)
    print num_patterns, expected_distinct, (1 - expected_distinct)


0 1.000000000 0
1 0.9900000000 0.01000000000
2 0.9801000000 0.01990000000
3 0.9702990000 0.02970100000
4 0.9605960100 0.03940399000
5 0.9509900499 0.04900995010
6 0.9414801494 0.05851985060
7 0.9320653479 0.06793465209
8 0.9227446944 0.07725530557
9 0.9135172475 0.08648275251
10 0.9043820750 0.09561792499
11 0.8953382543 0.1046617457
12 0.8863848717 0.1136151283
13 0.8775210230 0.1224789770
14 0.8687458128 0.1312541872
15 0.8600583546 0.1399416454
16 0.8514577711 0.1485422289
17 0.8429431934 0.1570568066
18 0.8345137615 0.1654862385
19 0.8261686238 0.1738313762
20 0.8179069376 0.1820930624
21 0.8097278682 0.1902721318
22 0.8016305895 0.1983694105
23 0.7936142836 0.2063857164
24 0.7856781408 0.2143218592
25 0.7778213594 0.2221786406
26 0.7700431458 0.2299568542
27 0.7623427143 0.2376572857
28 0.7547192872 0.2452807128
29 0.7471720943 0.2528279057
30 0.7397003734 0.2602996266
31 0.7323033697 0.2676966303
32 0.7249803360 0.2750196640
33 0.7177305326 0.2822694674
34 0.7105532273 0.2894467727
35 0.7034476950 0.2965523050
36 0.6964132181 0.3035867819
37 0.6894490859 0.3105509141
38 0.6825545950 0.3174454050
39 0.6757290491 0.3242709509
40 0.6689717586 0.3310282414
41 0.6622820410 0.3377179590
42 0.6556592206 0.3443407794
43 0.6491026284 0.3508973716
44 0.6426116021 0.3573883979
45 0.6361854861 0.3638145139
46 0.6298236312 0.3701763688
47 0.6235253949 0.3764746051
48 0.6172901409 0.3827098591
49 0.6111172395 0.3888827605
50 0.6050060671 0.3949939329
51 0.5989560065 0.4010439935
52 0.5929664464 0.4070335536
53 0.5870367819 0.4129632181
54 0.5811664141 0.4188335859
55 0.5753547500 0.4246452500
56 0.5696012025 0.4303987975
57 0.5639051905 0.4360948095
58 0.5582661385 0.4417338615
59 0.5526834772 0.4473165228
60 0.5471566424 0.4528433576
61 0.5416850760 0.4583149240
62 0.5362682252 0.4637317748
63 0.5309055430 0.4690944570
64 0.5255964875 0.4744035125
65 0.5203405226 0.4796594774
66 0.5151371174 0.4848628826
67 0.5099857462 0.4900142538
68 0.5048858888 0.4951141112
69 0.4998370299 0.5001629701
70 0.4948386596 0.5051613404
71 0.4898902730 0.5101097270
72 0.4849913703 0.5150086297
73 0.4801414566 0.5198585434
74 0.4753400420 0.5246599580
75 0.4705866416 0.5294133584
76 0.4658807752 0.5341192248
77 0.4612219674 0.5387780326
78 0.4566097477 0.5433902523
79 0.4520436503 0.5479563497
80 0.4475232138 0.5524767862
81 0.4430479816 0.5569520184
82 0.4386175018 0.5613824982
83 0.4342313268 0.5657686732
84 0.4298890135 0.5701109865
85 0.4255901234 0.5744098766
86 0.4213342222 0.5786657778
87 0.4171208799 0.5828791201
88 0.4129496711 0.5870503289
89 0.4088201744 0.5911798256
90 0.4047319727 0.5952680273
91 0.4006846530 0.5993153470
92 0.3966778064 0.6033221936
93 0.3927110284 0.6072889716
94 0.3887839181 0.6112160819
95 0.3848960789 0.6151039211
96 0.3810471181 0.6189528819
97 0.3772366469 0.6227633531
98 0.3734642805 0.6265357195
99 0.3697296376 0.6302703624

Expected performance for first-order TMs with varying sparsity


In [53]:
eq1 = subsampledFpF
expected_num_segments_per_cell = (19*1000)*a/n
eq2 = 1 - ((1 - subsampledFpF)**expected_num_segments_per_cell)
jaccard = a/(a + eq2*(n - a))
display(jaccard)
jaccard2 = jaccard.subs(a, 64).subs(theta, 10).subs(s, 25)
display(jaccard2)
print "["
for i in range(300, 4100, 100):
    eq4 = jaccard2.subs(n, i)
    print i, str(eq4.evalf(10)), expected_num_segments_per_cell.subs(a, 64).subs(n, i).evalf(), eq2.subs(a, 64).subs(theta, 10).subs(s, 25).subs(n, i).evalf()
print "]"


$$\frac{a}{a + \left(- a + n\right) \left(- \left(- \sum_{b=\theta}^{s} \frac{{\binom{s}{b}}}{{\binom{n}{a}}} {\binom{n - s}{a - b}} + 1\right)^{\frac{19000 a}{n}} + 1\right)}$$
$$\frac{64}{\left(n - 64\right) \left(- \left(- \sum_{b=10}^{25} \frac{{\binom{25}{b}}}{{\binom{n}{64}}} {\binom{n - 25}{- b + 64}} + 1\right)^{\frac{1216000}{n}} + 1\right) + 64}$$
[
300 0.2133333333 4053.33333333333 1.00000000000000
400 0.1600638971 3040.00000000000 0.999524764597103
500 0.1888256286 2432.00000000000 0.630589545802401
600 0.4262461218 2026.66666666667 0.160723868815488
700 0.7258061642 1737.14285714286 0.0380154287753211
800 0.8951305190 1520.00000000000 0.0101874364838613
900 0.9609518686 1351.11111111111 0.00311080162482483
1000 0.9846976836 1216.00000000000 0.00106257204324782
1100 0.9935867156 1105.45454545455 0.000398744719297588
1200 0.9971328657 1013.33333333333 0.000161993146411579
1300 0.9986419067 935.384615384615 7.04176141864219e-5
1400 0.9993231120 868.571428571429 3.24477365229332e-5
1500 0.9996471912 810.666666666667 1.57296170224554e-5
1600 0.9998086985 760.000000000000 7.97242199767715e-6
1700 0.9998925696 715.294117647059 4.20310689761942e-6
1800 0.9999377508 675.555555555556 2.29504468162097e-6
1900 0.9999629020 640.000000000000 1.29322365878282e-6
2000 0.9999773229 608.000000000000 7.49672456579212e-7
2100 0.9999858153 579.047619047619 4.45889875695127e-7
2200 0.9999909394 552.727272727273 2.71481298138744e-7
2300 0.9999941004 528.695652173913 1.68863354280829e-7
2400 0.9999960903 506.666666666667 1.07114617319835e-7
2500 0.9999973667 486.400000000000 6.91839375383425e-8
2600 0.9999981996 467.692307692308 4.54367594173651e-8
2700 0.9999987518 450.370370370370 3.03056076786371e-8
2800 0.9999991234 434.285714285714 2.05057982535601e-8
2900 0.9999993769 419.310344827586 1.40618219377182e-8
3000 0.9999995521 405.333333333333 9.76412284041323e-9
3100 0.9999996746 392.258064516129 6.85968217059619e-9
3200 0.9999997613 380.000000000000 4.87235129623575e-9
3300 0.9999998232 368.484848484848 3.49663416869302e-9
3400 0.9999998679 357.647058823529 2.53382779266200e-9
3500 0.9999999005 347.428571428571 1.85301892764823e-9
3600 0.9999999245 337.777777777778 1.36690667633440e-9
3700 0.9999999422 328.648648648649 1.01660491325226e-9
3800 0.9999999555 320.000000000000 7.61962852667373e-10
3900 0.9999999655 311.794871794872 5.75323088828602e-10
4000 0.9999999731 304.000000000000 4.37448757931150e-10
]

In [ ]:


In [ ]: