Nowadays there are heaps of articles on the theory of fuzzy entropy and fuzzy mutual information. However, there is a clear significant lack for a Matlab implementation of these concepts. Based on numerous requests from students and researchers, I have prepared this code to simplify such concepts and give a tool that you can try directly. Of course, you may find heaps of different methods by which you may enhance the functionality of the code, so please feel free to inform me and the rest of any such updates overhere. Kindly, if you use this code then cite either of the following papers:
 R. N. Khushaba, A. Al-Jumaily, and A. Al-Ani, “Novel Feature Extraction Method based on Fuzzy Entropy and Wavelet Packet Transform for Myoelectric Control”, 7th International Symposium on Communications and Information Technologies ISCIT2007, Sydney, Australia, pp. 352 – 357.
 R. N. Khushaba, S. Kodagoa, S. Lal, and G. Dissanayake, “Driver Drowsiness Classification Using Fuzzy Wavelet Packet Based Feature Extraction Algorithm”, IEEE Transaction on Biomedical Engineering, vol. 58, no. 1, pp. 121-131, 2011.
 Ahmed Al-Ani, Rami N. Khushaba, "A Population Based Feature Subset Selection Algorithm Guided by Fuzzy Feature Dependency", AMLTA 2012, CCIS 322, pp. 430–438, 2012.
P.S: Let me know about bugs, if any.
Dr. Rami N. Khushaba
Thanks for providing the code Sir, I was having the following doubt after reading your paper. I wanted to understand how the equations (11) and (13) in the paper are implemented in your code. But I was not able to succeed in understanding hence seek your help.
R. N. Khushaba, S. Kodagoda, S. Lal, and G. Dissanayake, “Driver Drowsiness Classification Using Fuzzy Wavelet Packet Based Feature Extraction Algorithm”, IEEE Transaction on Biomedical Engineering, vol. 58, no. 1, pp. 121-131, 2011. (ERA Ranking: A*)
What is the technical term for Ps_Cx used in the code? Why are non-diagonal fuzzy memberships also multiplied by each other in the expression below:
suppose A=(U(:,:,i)'.*matC)' when it is multiplied by A', output contains non diagonal elements also, shouldn't it be sum(sqrt(A.*A))...
Kindly assist sir,
Can somebody please tell me , how we can use this code for measuring entropy of ecg signal?
Good~But it is a little time consuming
in function [fea] = mrmr_mid_d(d, f, K,I_Cx,I_xx) what would be the value of I_Cx and I_xx ?
Hi every body
I'm working in feature selection with BPSO using Mutual information (By Hanchuan Peng April 16, 2003)
and i have faced problem with code
Subscript indices must either be real positive integers or logicals.
Error in BPSO (line 47)
can any one help me pleas..
thank you for sharing it! i have a question i tried your fuzzy code with a signal with gaussian nose and always return de same value
i'm wondering if is possible to read “Novel Feature Extraction Method based on Fuzzy Entropy and Wavelet Packet Transform for Myoelectric Control” for understand how to enter the input signal ..i was looking in internet but i cant find it!
Just make sure that your class label, this is the last column in data, is actually organized as 1 2 3 4 etc..., i.e., the label haves consecutive numbering and in that case you can ignore or comment the grp2idx function.
Thanks, but does it require Statistics Toolbox?
I get "Undefined function 'grp2idx' for input arguments of type 'double'".
For those interested in mutual information based feature selection, you can use this code with the well-known MRMR feature selection algorithm from: http://www.mathworks.com.au/matlabcentral/fileexchange/14916-minimum-redundancy-maximum-relevance-feature-selection
You will have to adjust the fuzzification parameter m to reflect better performance. You will also have to modify the original function by Hanchuan Peng into the following:
function [fea] = mrmr_mid_d(d, f, K,I_Cx,I_xx)
% MID scheme according to MRMR
% Original By Hanchuan Peng
% April 16, 2003
% Modification By Rami Khushaba
nd = size(d,2);
nc = size(d,1);
t = I_Cx;
[tmp, idxs] = sort(t,'descend');
fea_base = idxs(1:K);
fea(1) = idxs(1);
KMAX = min(1000,nd); %500
idxleft = idxs(2:KMAX);
fprintf('k=1 cost_time=(N/A) cur_fea=%d #left_cand=%d\n', ...
ncand = length(idxleft);
curlastfea = length(fea);
t_mi(i) = I_Cx(idxleft(i));
mi_array(idxleft(i),curlastfea) = I_xx(fea(curlastfea), idxleft(i));
c_mi(i) = mean(mi_array(idxleft(i), :));
[tmp, fea(k)] = max(t_mi(1:ncand) - c_mi(1:ncand));
tmpidx = fea(k); fea(k) = idxleft(tmpidx); idxleft(tmpidx) = ;
fprintf('k=%d cost_time=%5.4f cur_fea=%d #left_cand=%d\n', ...
k, cputime-t1, fea(k), length(idxleft));
Post any question related to fuzzy MI and I will try to reply as soon as possible.
many many thanks for your sharing.
thank you very much！I got it
Liu, an example is included in the code.
Thank you for sharing it.In fact i want to download 'Fuzzy Mutual Information and Fuzzy Entropy '.How use it?
Thank you very much Dr. Rami for sharing this great code
The estimation is more accurate now, you can even plug it with the well-known MRMR feature selection and try it instead of the C++ MI toolbox that comes with MRMR algorithm.
I_xx estimation corrected with an example showing the values of I_xx and H_x when we have two completely redundant features.
The estimation of I_Cxx and I_xx have been updated into a better version now. Old versions are also included but commented for future use. If you find any bugs kindly let me know.