Is there a method in numpy that calculates the ratio of entries in an array over the sum of the numbers in the array? For example:
>>>import numpy as np
>>>datas=[1,2,3,3,100]
>>>np.frequencies(datas)
[1/109,2/109,3/109,3/109,100/109]
Is there a method in numpy that calculates the ratio of entries in an array over the sum of the numbers in the array? For example:
>>>import numpy as np
>>>datas=[1,2,3,3,100]
>>>np.frequencies(datas)
[1/109,2/109,3/109,3/109,100/109]
Assuming I understand what you're saying you can just do the following
import numpy as np
datas=np.asarray([1,2,3,3,100]) # Convert to a numpy array
answer_you_want = datas / sum(datas)