https://github.com/PerezOrtegaJ/Neural_Ensemble_Analysis
Raw File
Tip revision: 9d37fd031dfbdb4eb69faa449d0a6416267a7d4f authored by Jesús Pérez on 28 July 2020, 20:36:58 UTC
Update README.md
Tip revision: 9d37fd0
Get_Entropy.m
function entropy = Get_Entropy(frequencies)
% Entropy from a list of frequencies
%
% By Pérez-Ortega Jesús, Feb 2019

n = length(frequencies);
total = sum(frequencies);

if(~total)
    entropy = nan;
    return
end

p = frequencies/total;

entropy = 0;
for i = 1:n
    if(p(i))
        entropy = entropy + p(i)*log2(p(i));
    end
end
entropy = -entropy;
back to top