Use :
norm = [float(i)/sum(raw) for i in raw]
to normalize against the sum to ensure that the sum is always 1.0 (or as close to as possible).
use
norm = [float(i)/max(raw) for i in raw]
to normalize against the maximum
More Related Contents:
- Find the similarity metric between two strings
- Python – Is a dictionary slow to find frequency of each character?
- How to incrementally sample without replacement?
- How do I simulate flip of biased coin?
- Defined variable is not defined
- Adding a element in dictionary which consist of dictionaries.
- Select nan column in pandas
- How to make Firefox headless programmatically in Selenium with Python?
- Matplotlib scatterplot; color as a function of a third variable
- Remove duplicates by columns A, keeping the row with the highest value in column B
- Usage of sys.stdout.flush() method
- Time complexity of python set operations?
- What is the correct way to set Python’s locale on Windows?
- Calling functions from a Tkinter Frame to another
- Render NumPy array in FastAPI
- How to create a hyperlink with a Label in Tkinter?
- Dimension of shape in conv1D
- UnicodeDecodeError: (‘utf-8’ codec) while reading a csv file [duplicate]
- Determine the common prefix of multiple strings
- How can I register a single view (not a viewset) on my router?
- How to multiply two 2D RFFT arrays (FFTPACK) to be compatible with NumPy’s FFT?
- pytest using fixtures as arguments in parametrize
- How to write custom python logging handler?
- Good ways to sort a queryset? – Django
- Convert a string to preexisting variable names
- Is it possible to add hatches to each individual bar in seaborn.barplot?
- Can I convert spectrograms generated with librosa back to audio?
- How to add a new column to the beginning of the rows of a CSV file?
- Python – returning from a Tkinter callback
- Is there any way to show the dependency trees for pip packages?