arvoelke / nengolib

Nengo library of additional extensions
Other
29 stars 6 forks source link

[ENH] PerfectLIF default neuron; improves spike timing #29

Closed arvoelke closed 8 years ago

arvoelke commented 8 years ago

This significantly improves the error of the default neuron type in Nengo, by solving for the exact point within the timestep at which the voltage crosses the threshold (as opposed to being linearly interpolated), and then maintaining the refractory period exactly in a similar manner.

This all works from the assumption that our inputs are piecewise-constant across each [t, t + dt) interval. In this case, discretizing the neuron's lowpass filter with time-constant tau gives the voltage update:

v(t) = v(0) + (J - v(0)) * (1 - exp(-t/tau))

With this, we can substitute the time leftover from the refractory period into t to account perfectly for the refractory period. In addition, we can set v(0) = 1 and solve for t to get the time between when the voltage crosses the threshold and the end of the timestep. We then subtract this from dt to get the time of the spike:

dt + tau * ln(1 - (v(t) - 1)/(J - 1))

Which we then use to update the refractory_period appropriately.

codecov-io commented 8 years ago

Current coverage is 100.00%

Merging #29 into master will not affect coverage as of 6e13efd

@@            master     #29   diff @@
======================================
  Files           14      15     +1
  Stmts          621     636    +15
  Branches        80      80       
  Methods          0       0       
======================================
+ Hit            621     636    +15
  Partial          0       0       
  Missed           0       0       

Review entire Coverage Diff as of 6e13efd

Powered by Codecov. Updated on successful CI builds.