لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

Python Data Science NumPy Random Chi Data Distribution

Chi Distribution: is used as a basis to verify the hypothesis.

It has the following two parameters

1. df - (degree of freedom).

2. size - The shape of the returned array.

Example 1: Draw out a sample for chi squared distribution with degree of freedom 2 with size 2x4.

Code

from numpy import random

x = random.chisquare(df=2, size=(2, 4))

print(x)

the output will be

[[1.14834891 1.6585861 4.02789576 1.97763259]

[7.32769876 0.67269554 4.36897044 8.94641364]]

Note: Every time the code is run the output may vary because of random generation.

Visualization of Chi Square Distribution

Example 2

Code

from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns

sns.distplot(random.
chisquare(df=2, size=100000), hist=False)

plt.show()

the output will be