# sciPy stats.cumfreq() function | Python

`scipy.stats.cumfreq(a, numbins, defaultreallimits, weights) ` works using the histogram function and calculates the cumulative frequency histogram. It includes cumulative frequency binned values, width of each bin, lower real limit, extra points.

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.

Results :
– cumulative frequency binned values
– width of each bin
– lower real limit
– extra points.

Code #1:

 `# cumulative frequency ` `from` `scipy ``import` `stats ` `import` `numpy as np  ` ` `  `arr1 ``=` `[``1``, ``3``, ``27``, ``2``, ``5``, ``13``]  ` `print` `(``"Array element : "``, arr1, ``"\n"``) ` ` `  `a, b, c, d ``=` `stats.cumfreq(arr1, numbins ``=` `4``) ` ` `  `print` `(``"cumulative frequency : "``, a) ` `print` `(``"Lower Limit : "``, b) ` `print` `(``"bin size : "``, c) ` `print` `(``"extra-points : "``, d) `

Output:

```Array element :  [1, 3, 27, 2, 5, 13]

cumulative frequency :  [ 4.  5.  5.  6.]
Lower Limit :  -3.33333333333
bin size :  8.66666666667
extra-points :  0
```

Code #2:

 `# cummulative frequency ` `from` `scipy ``import` `stats ` `import` `numpy as np  ` ` `  `arr1 ``=` `[``1``, ``3``, ``27``, ``2``, ``5``, ``13``]  ` `print` `(``"Array element : "``, arr1, ``"\n"``) ` ` `  `a, b, c, d ``=` `stats.cumfreq(arr1, numbins ``=` `4``, ` `              ``weights ``=` `[.``1``, .``2``, .``1``, .``3``, ``1``, ``6``]) ` ` `  `print` `(``"cumfreqs : "``, a) ` `print` `(``"lowlim : "``, b) ` `print` `(``"binsize : "``, c) ` `print` `(``"extrapoints : "``, d) `

Output:

```Array element :  [1, 3, 27, 2, 5, 13]

cumfreqs :  [ 1.6  7.6  7.6  7.7]
lowlim :  -3.33333333333
binsize :  8.66666666667
extrapoints :  0
```

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.