Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

entropy python

import numpy as np

# 3 decimal points
round = 3

# entropy(q) = -( q * log2(q) + (1-q) * log2(1-q) )
def entropy(q):
    entropy = -(q * np.log2(q) + (1-q) * np.log2(1-q))
    entropy = np.round(entropy, round)
    return entropy
  
# print(entropy(0.3)) = 0.881
Comment

PREVIOUS NEXT
Code Example
Python :: how to factorise expressions in python 
Python :: check if numpy array is 1d 
Python :: datetime python timezone 
Python :: Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory. 
Python :: python cache return value 
Python :: python seconds counter 
Python :: create dataframe from csv and name columns pandas 
Python :: create a dataframe with series 
Python :: Get value from TextCtrl wxpython 
Python :: pandas read csv read all rows except one 
Python :: Savefig cuts off title 
Python :: pandas row number by group 
Python :: numpy add axis 
Python :: matplotlib bold 
Python :: python check if value is undefined 
Python :: python teilen ohne rest 
Python :: position in list python 
Python :: selenium text returns empty string python 
Python :: create directory python if not exist 
Python :: python for loop m to n 
Python :: messages django 
Python :: split dataset into train, test and validation sets 
Python :: python convert int to bool 
Python :: how to change the window colour in pygame 
Python :: `distplot` is a deprecated function and will be removed in a future version 
Python :: number of columns with no missing values 
Python :: remove trailing and leading spaces in python 
Python :: python aritmethic print 
Python :: number pyramid pattern in python 
Python :: python tqdm while loop 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =