Created
March 17, 2020 12:09
-
-
Save tindzk/702317175da0ee1e7723b2f53982b38c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% | |
% Generate Poission spike train using a uniform probability distribution | |
% | |
% Generates up to r * T spikes. | |
% None of the spike times will exceed T. | |
% | |
% @param r firing rate (Hz) | |
% @param T spike train duration (seconds) | |
% @param dt time resolution (seconds) | |
% @return V Spike times (seconds) | |
% @return B Binned spike train | |
function [V, B] = poisson(r, T, dt) | |
% Number of bins | |
b = T / dt; | |
% Threshold value | |
v = r * dt; | |
% Generate bins by drawing b random numbers | |
B = rand(1, b); | |
% No spike if random numbers exceed v | |
B(B >= v) = 0; | |
% All other values are spikes | |
B(B > 0) = 1; | |
% Determine spike times | |
V = find(B == 1) * dt; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment