- double
- single
- int8
- uint8
- int16
- uint16
- int32
- uint32
- int64
- uint64
- logical
- char
if i execute its saying type input argument and run the code ? what input argument must type inside that ? please help me
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
% Entropy: Returns entropy (in bits) of each column of 'X'
% by Will Dwinnell
%
% H = Entropy(X)
%
% H = row vector of calculated entropies (in bits)
% X = data to be analyzed
%
% Example: Measure sample entropy of observations of variables with
% 1, 2, 3 and 4 bits of entropy.
%
% Note: Estimated entropy values are slightly less than true, due to
% finite sample size.
%
% X = ceil(repmat([2 4 8 16],[1e3,1]) .* rand(1e3,4));
% Entropy(X)
%
% Last modified: Nov-12-2006
function H = Entropy(X)
% Establish size of data
[n m] = size(X);
% Housekeeping
H = zeros(1,m);
for Column = 1:m,
% Assemble observed alphabet
Alphabet = unique(X(:,Column));
% Housekeeping
Frequency = zeros(size(Alphabet));
% Calculate sample frequencies
for symbol = 1:length(Alphabet)
Frequency(symbol) = sum(X(:,Column) == Alphabet(symbol));
end
% Calculate sample class probabilities
P = Frequency / sum(Frequency);
% Calculate entropy in bits
% Note: floating point underflow is never an issue since we are
% dealing only with the observed alphabet
H(Column) = -sum(P .* log2(P));
end
% God bless Claude Shannon.
% EOF
0 Commenti
Risposte (1)
Walter Roberson
il 26 Gen 2016
That routine should work if you pass it a column vector or 2D matrix, with any of the data types:
However, it would fail if you were to pass it a cell array or struct of any kind. (There is an easy modification that would permit it to work with cell arrays of string.)
0 Commenti
Vedere anche
Categorie
Scopri di più su Text Analytics Toolbox in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!