How to Generate Samples from Noncentral chi-Square Distribution
To generate random samples from a noncentral chi-square distribution we use random.noncentral_chisquare() method of the NumPy library.
Let us understand it better with an example:
Example
Python3
# import numpy import numpy as np import matplotlib.pyplot as plt # Using noncentral_chisquare() method gfg = np.random.noncentral_chisquare( 14.05 , 3.24 , 3000 ) count, bins, ignored = plt.hist(gfg, 14 , density = True ) plt.show() |
Output
NumPy random.noncentral_chisquare() | Draw Samples From Noncentral chisqaure
The NumPy random.noncentral_chisquare() method returns samples from a noncentral chisquare distribution.
Example:
Python3
import matplotlib.pyplot as plt import numpy as np gfg = np.random.noncentral_chisquare( 1.21 , 9.89 , 1000 ) count, bins, ignored = plt.hist(gfg, 30 , density = True ) plt.show() |
Output :