% lif:
noises = [ 1e-5 1e-4 1e-3 1e-2 1e-1 ];
inputs = 0:0.1:20;
duration = 50.0;
% pif:
% noises = [ 1e-1 1 1e1 1e2 1e3 ];
% inputs = -5:0.1:10;
% duration = 100.0;

f = figure;
hold all;
for noise = noises
    fprintf( 'noise=%.0e\n', noise );
    rates = [];
    for input = inputs
        spikes = lifspikes( 10, input, duration, noise );
        % spikes = pifspikes( 50, input, duration, noise );
        nspikes = 0;
        for k = 1:length( spikes )
            nspikes = nspikes + length( spikes{k} );
        end
        rate = nspikes/duration/length( spikes );
        %fprintf( 'I=%g  N=%d  rate=%g\n', input, length( spikes ), rate )
        rates = [ rates rate ];
    end
    plot( inputs, rates, 'LineWidth', 2, 'DisplayName', sprintf( 'D=%.0e', noise ) );
end
xlabel( 'Input' );
xlim( [ inputs(1) inputs(end) ] )
ylabel( 'Firing rate [Hz]' );
%title( 'Leaky integrate-and-fire' )
title( 'Perfect integrate-and-fire' )
legend( '-DynamicLegend', 'Location', 'NorthWest' )
hold off


