function [fano, n_i] = fano_factor(spike_train, l_c)
%   Computes the Fano factor of spike counts
%   in n_i counting intervals of length l_c

%   NEUR 1680
%   Last updated 02/08/2012

N = length(spike_train);

n_i = floor(N/l_c);                             % number of counting intervals to be used
n_c = l_c*n_i;                                  % length of record to be used
r_s_t = reshape(spike_train(1:n_c),l_c,n_i);    % reshaped spike train
counts = sum(r_s_t,1);                          % spike counts
fano = var(counts)/mean(counts);                % Fano factor
