scipy.stats.histogram (a, numbins, defaultreallimits, weights, printextras)
works to split a range into multiple bins and then returns the number of instances in each bin. This function is used to build a histogram.
Parameters:
arr: [array_like] input array.
numbins: [int] number of bins to use for the histogram. [Default = 10]
defaultlimits: (lower, upper) range of the histogram.
weights: [array_like] weights for each array element.
printextras: [array_like] to print the no, if extra points to the standard output, if trueResults:
- cumulative frequency binned values
- width of each bin
- lower real limit
- extra points.
Code # 1:
|
Output:
No. of points in each bin: [0 2 4 1] Size of the bins: [0 1 2 3 4]