使用Python中的NumPy计算一组数据的直方图
直方图是数据集分布的图形表示。它以一系列的条形图的形式表示数据,其中每个条形图代表的数据值范围,条形图的高度代表在该范围内定义的数据值的频率。
这些主要用于表示数值数据的分布,如班级中的成绩分布,人口分布或员工收入分布等。
In histogram, x-axis represents the range of data values, divided into intervals and the y-axis represents the frequency of the range of data values within each bin. Histograms can be normalized by dividing the frequency of each bin by the total data values, which results to the relative frequency histogram where y-axis represents the data values of each bin.
Calculating histogram using Python Numpy
In python, for creating the histograms we have numpy, matplotlib and seaborn libraries. In Numpy, we have the function named histogram() to work with the histogram data.
语法
Following is the syntax for creating the histograms for the given range of data.
numpy.histogram(arr, bins, range, normed, weights, density) 登录后复制