I have an array of numbers:
q1a = [1,2,2,2,4,3,1,3,3,4,0,0]
I want to save these in an array where it will be stored in as (number, proportion of the number) using PYTHON.
Such as : [[0 0.1667], [1 0.1667], [2 0.25], [3 0.25], [4 0.167]].
This is essential to calculate the distribution of the numbers. How can I do this?
Although I wrote the code to save the numbers as : (number, number of times it occurred in the list) but I cant figure it out how I can find the proportion of each number. Thanks.
sorted_sample_values_of_x = unique, counts = np.unique(q1a, return_counts=True)
np.asarray((unique, counts)).T
np.put(q1a, [0], [0])
sorted_x = np.matrix(sorted_sample_values_of_x)
sorted_x = np.transpose(sorted_x)
print('\n' 'Values of x (sorted):' '\n')
print(sorted_x)