Search notes:

Entropy

Entropy measures the uncertainity or information of a random variable.
from   numpy        import array
from   scipy.stats  import entropy
from   math         import log

base = 2


def e(*a):
    H = entropy(array(a), base=base)
    print(H)           

e( 1                           ) # 0.0                       | maximum value
e( 1/2     , 1/2               ) # 1.0                       | maximum value
e( 0.00001 , 0.99999           ) # 0.00018052328301819962    |
e( 1/3     , 1/3     , 1/3     ) # 1.584962500721156         | maximum value
e( 0.00001 , 0.00001 , 0.99998 ) # 0.00036104642176561263

#
# Maximum entropy for 1, 2 and 3 categories:
#
print(log(1, base)) # 0.0
print(log(2, base)) # 1.0
print(log(3, base)) # 1.5849625007211563

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/science/...', 1759612595, '216.73.216.149', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/science/mathematics/statistics/entropy(56): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78