Shannon entropy calculation

I have a probability distribution that determines the probability of occurrence of npossible states.

I would like to calculate the value of the Shannon entropy in bits of a given probability distribution.

Can I use wentropy(x,'shannon')to get the value, and if so, where can I determine the number of possible states that the system has?

+4
source share
1 answer

Since you already have a probability distribution, name it p, you can make the following formula for Shannon entropy instead of using wentropy:

H = sum(-(p(p>0).*(log2(p(p>0)))));

H .

p 1.

+8

Source: https://habr.com/ru/post/1529251/


All Articles