inputs = 0:0.1:20;  % lif
inputs = 0:0.1:10; % pif
avisi = [];
sdisi = [];
cvisi = [];
dcisi = [];

for input = inputs
    input
    % spikes = lifspikes( 100, input, 100.0, 1e-2 );
    spikes = pifspikes( 100, input, 100.0, 1e-1 );
    isivec = isis( spikes );
    if length( isivec ) <= 1
        av = Inf;
        sd = NaN;
        cv = NaN;
        dc = NaN;
    else
        av = mean( isivec );
        sd = std( isivec );
        if av > 0.0 
            cv = sd/av;
            dc = sd^2.0/2.0/av^3;
        else
            cv = NaN;
            dc = NaN;
        end
    end
    avisi = [ avisi av ];
    sdisi = [ sdisi sd ];
    cvisi = [ cvisi cv ];
    dcisi = [ dcisi dc ];
end

f = figure;
subplot( 2, 2, 1 );
plot( inputs, 1.0./avisi, '-b', 'LineWidth', 3 );
xlabel( 'Input' );
xlim( [ inputs(1) inputs(end) ] )
title( 'Mean rate [Hz]' );

subplot( 2, 2, 2 );
plot( inputs, 1000.0*avisi, '-b', 'LineWidth', 3 );
hold on;
plot( inputs, 1000.0*sdisi, '-c', 'LineWidth', 3 );
hold off;
xlabel( 'Input' );
xlim( [ inputs(1) inputs(end) ] )
ylim( [ 0 1000 ] )
title( 'ISI [ms]' );
legend( 's.d. ISI', 'mean ISI' );

subplot( 2, 2, 3 );
plot( inputs, cvisi, '-b', 'LineWidth', 3 );
xlabel( 'Input' );
xlim( [ inputs(1) inputs(end) ] )
title( 'CV' );

subplot( 2, 2, 4 );
plot( inputs, dcisi, '-b', 'LineWidth', 3  );
xlabel( 'Input' );
xlim( [ inputs(1) inputs(end) ] )
title( 'D [Hz]' );
