function [Ifish, Imut] = fig2_AB(N, fTau)
% fig2_AB  Reproduce points from Figure 2A and 2B
% 
% [Ifish, Imut] = fig2_AB(N, fTau) calculates the mutual information and I_Fisher for:
% population size N neurons
% variability F/tau = fTau spikes/s^2

% Stuart Yarrow s.yarrow@ed.ac.uk - 15/11/2011

tic

stderr = 2e-2;      % Target relative error for MC halting
maxiter = 1e5;      % MC iteration limit

tau = 1.0;          % integration time (s)
F = fTau .* tau;    % Fano factor
alpha = 0.5;        % variability exponent
fmax = 50.0;        % peak firing rate (spikes/s)
fbg = 10.0;         % background firing rate (spikes/s)
sigma = 30.0;       % tuning curve width parameter (degrees)

% Preferred stimuli
nrns = [-180 : 360/N : 180-360/N];

% Define stimulus ensemble and population
stim = StimulusEnsemble('circular', 360, 360);
popNrns = CircGaussNeurons(nrns, sigma, fmax, fbg, tau, 'Gaussian-independent', [F alpha]);

% Compute measures
Ifish = popNrns.Ifisher(stim);
[Imut, ImutSEM, ImutSamps] = popNrns.mi('randMC', stim, stderr, maxiter);
    
fprintf('fig2_AB.m\n')
fprintf('Parameters: N = %d neurons, F/tau = %g spikes/s^2\n', N, fTau)
fprintf('I_Fisher = %g bits\n', Ifish)
fprintf('I_mut = %g bits with StdErr %g bits\n', Imut, ImutSEM)
fprintf('I_mut - I_Fisher = %g bits\n', Imut - Ifish)