numpy.random.chisquare() in Python
Last Updated :
15 Jul, 2020
With the help of chisquare() method, we can get chi-square distribution by using this method. Mainly we can use this distribution in hypothesis testing.
chi-square distribution
Syntax : numpy.random.chisquare(df, size=None)
Parameters :
1) df – number of degree of freedom and must be >0.
2) size – Output shape of scalar array.
Return : Return the scalar numpy array.
Example #1 :
In this example we can see that by using chisquare() method, we are able to get the chi-square distribution and return the scalar numpy array by using this method.
Python3
import numpy as np
import matplotlib.pyplot as plt
gfg = np.random.chisquare( 3 , 1000 )
count, bins, ignored = plt.hist(gfg, 14 , density = True )
plt.show()
|
Output :
Example #2 :
Python3
import numpy as np
import matplotlib.pyplot as plt
gfg = np.random.chisquare( 5 , 10000 )
gfg1 = np.random.chisquare(gfg, 10000 )
count, bins, ignored = plt.hist(gfg1, 30 , density = True )
plt.show()
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...