I am trying to calculate the spectral entropy of an array as follows:
array([0.00000000e+00, 1.00743814e-04, 2.01487627e-04, 2.20497985e+01,
2.20498993e+01, 2.20500000e+01])
From this, I derived my code. however, I found my data was float and so I also adapted code from here to formulate the following:
>>> def ent(data):
... uniqw, inverse = np.unique(data, return_inverse=True)
... p_data= np.bincount(inverse)/len(data) # calculates the probabilities
... ent=entropy(p_data) # input probabilities to get the entropy
... return ent
The result is
>>> ent(freqArray)
1.791759469228055
How do I make my entropy lie between 0 and 1