%input = 65.0;   % lifadapt 100Hz
%input = 8.0;   % lifadapt 10Hz
input = 15.7;  % lif 100Hz
%input = 8.3;   % lif 10Hz
trials = 10;
tmax = 100.0;
noise = 1e-1;
adapttau = 0.1;
adaptincr = 5.0;

% generate spikes:
spikes = lifspikes( trials, input, tmax, noise );
%spikes = lifadaptspikes( trials, input, tmax, noise, adapttau, adaptincr );

% interspike intervals:
isivec = isis( spikes );
% histogram
f = figure( 1 );
isihist( isivec, 10e-4 );
hold on
% theoretical density:
misi = mean( isivec );
disi = var( isivec )/2.0/misi^3;
xmax = 3.0*misi;
x = 0:0.0001:xmax;
plot( 1000.0*x, inversegauss( x, misi, disi ), 'r', 'LineWidth', 3 );
% plot details:
title( sprintf( 'LIF, input=%g, nisi=%d', input, length( isivec ) ) )
xlim( [ 0.0 1000.0*xmax ] )
legend( 'data', 'inverse Gaussian' )
hold off

% serial correlations:
f = figure( 2 );
isiserialcorr( isivec, 10 );