Matplotlib: How to convert a histogram to a discrete probability mass function?
问题 I have a question regarding the hist() function with matplotlib. I am writing a code to plot a histogram of data who's value varies from 0 to 1. For example: values = [0.21, 0.51, 0.41, 0.21, 0.81, 0.99] bins = np.arange(0, 1.1, 0.1) a, b, c = plt.hist(values, bins=bins, normed=0) plt.show() The code above generates a correct histogram (I could not post an image since I do not have enough reputation). In terms of frequencies, it looks like: [0 0 2 0 1 1 0 0 1 1] I would like to convert this