Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shannon's Entropy calculation

I have a probability distribution that defines the probability of occurrence of n possible states.

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

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

like image 982
Composer Avatar asked Feb 13 '23 16:02

Composer


1 Answers

Since you already have the probability distribution, call it p, you can do the following formula for Shannon Entropy instead of using wentropy:

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

This gives the entropy H in bits.

p must sum to 1.

like image 81
chappjc Avatar answered Feb 24 '23 01:02

chappjc