function [ sparseness ] = spars(Rate)
% Calculates sparseness a of a firing rate vector, Rolls and Treves 1998
%   Detailed explanation goes here
    N = floor(length(Rate));
    h_av = 0; % calc sparseness of the firing Rate representation of Rate 
    h2_av = 0;
    for neuron = 1 : N
        h_av = h_av + Rate(neuron) / N;
        h2_av = h2_av + (Rate(neuron) * Rate(neuron) / N);
    end
    sparseness =  h_av * h_av / h2_av;
end

