Skip to content
Back to formatted view

Raw Message

Message-ID: <3EBA826E.4030204@pdf.com>
Date: 2003-05-08T16:14:38Z
From: Spencer Graves
Subject: function to compute entropy

Have you considered:

	entropy<-sum(A*logb(A, 2))

hth.  spencer graves

Kosenkov Kirill wrote:
> Maybe its slightly off-topic, but can anybody
> help with computing entropy on matrix of probabilities?
> 
> Guess we have a matrix of probabilites, A, 2x2, something
> like this:
>    z
> x   0     1     2     3     4
>   0 0.063 0.018 0.019 0.016 0.000
>   1 0.011 0.162 0.040 0.042 0.003
>   2 0.015 0.030 0.164 0.033 0.002
>   3 0.012 0.035 0.036 0.159 0.002
>   4 0.004 0.021 0.018 0.013 0.082
> 
> sum(A)=1
> 
> Can i compute entropy like this:
> entropy<-sum(A*log2(A)) ?
> 
> is there a function for computing entropy in R?
> 
> Thanx.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help