In This Article, You Will Learn About Numpy chi-square Distribution.
Numpy Chi-square Distribution – Before moving ahead, let’s know a bit of Python Exponential Distribution
Chi-square distribution is a squared distribution that is used for statistical tests. In other words, it is used to test statistical tests where the test statistic follows Chi-squared distribution.
It includes two parameters –
df - Degree of freedom. size - Shape of the returned array.
Example – Creating an array of random numbers of size 3×3 for Chi-square distribution.
from numpy import random
z = random.chisquare(df=2, size=(3, 3))
print(z)
Output - [[3.17431893 0.31158006 1.36799217] [0.76598932 1.20045585 0.82961162] [0.0807137 3.39885294 5.11447682]]
As shown above, it returned an array of shape 3×3 containing random numbers.
Note: Later you will learn more in our Python Chi-square Distribution Tutorial.
Visualization of Chi Square Distribution
Example – Visualizing the Chi-square Distribution graph without histogram.
from numpy import random import matplotlib.pyplot as plt import seaborn as kl kl.distplot(random.chisquare(df=2.2, size=5000), hist=False) plt.show()
As a result, it returned visualized the Chi-square Distribution graph without histogram.
Example – Visualizing the Chi-square Distribution graph with histogram.
from numpy import random import matplotlib.pyplot as plt import seaborn as kl kl.distplot(random.chisquare(df=2.2, size=5000)) plt.show()
As a result, it returned visualized the Chi-square Distribution graph without histogram.
If you find anything incorrect in the above-discussed topic and have any further questions, please comment below.
Like us on