function [H] = entropy(v)

	H =0;
    	
	N= max(size(v));
	M= min(size(v));
	if(M<1) return; end;
	
	N=N*M;
	
	sum_ = sum(sum(v)) ;
	if (sum_<=0) return; end; 
	for i=1:N
		if (  v(i)*(1-v(i))   ==0 ) continue; end;
		if (v(i)<0) disp(' ERRROR : NEGATIVE WEIGHT IN DISTRIBUTION. EXIT'); pause ;return; end;		
		H = H - v(i)* log2(v(i)) ;
	end;
	
	H = H/sum_ + log2(sum_) ;
	
return;
	


