Change language

sciPy function stats.relfreq () | python

scipy.stats.relfreq (a, numbins, defaultreallimits, weights) is a relative frequency histogram using the histogram function.

Parameters:
arr: [array_like] input array.
numbins: Number of bins to use for the histogram. [Default = 10]
defaultreallimits: (lower, upper) range of the histogram.
weights: [array_like] weights for each array element.

Results:
- relative frequency binned values ​​
- width of each bin
- lower real limit
- extra points.

Code # 1:

# relative frequency

from scipy import stats

import numpy as np 

 

arr1 = [ 1 , 3 , 27 , 2 , 5 , 13

print ( " Array element: " , arr1, " " )

 

a, b, c, d = stats.relfreq (arr1, numbins = 4 )

  

print ( "cumulative frequency:" , a )

print ( "Lower Limit:" , b)

print ( "bin size:" , c)

print ( "extra-points:" , d)

Exit:

 Array element: [1, 3, 27, 2, 5, 13] cumulative frequency: [0.66666667 0.16666667 0. 0.16666667] Lower Limit: -3.333333333333333 bin size: 8.666666666666666 extra-points: 0 

Code # 2:

# relative frequency

from scipy import stats

import numpy as np 

 

arr1 = [ 1 , 3 , 27 , 2 , 5 , 13

print ( " Array element: " , arr1, "" )

 

a, b, c, d = stats.relfreq (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: [0.26666667 1. 0. 0.01666667] lowlim: -3.333333333333333 binsize: 8.666666666666666 extrapoints: 0 

Shop

Gifts for programmers

Learn programming in R: courses

$FREE
Gifts for programmers

Best Python online courses for 2022

$FREE
Gifts for programmers

Best laptop for Fortnite

$399+
Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best computer for crypto mining

$499+
Gifts for programmers

Best laptop for Sims 4

$

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically