FUNCTION entropy,p,s ;+ ;H=entropy(p) returns the entropy associated with the ;probability array p. If two arrays, p and s, are provided then ;the returned value is total(p*alog(s))/alog(2). The ;calculation is done over the nonzero values of the ;array in the logarithm. ; ;- IF n_params() EQ 1 then s=p IF abs(total(p) - 1.0) GT 1e-6 THEN MESSAGE,'Unacceptable probability array in argument' k=Where(s GT 0) return,-total(p[k]*alog(s[k]))/alog(2) end