NumPy random.noncentral_f() | Get Random Samples from noncentral F distribution
The NumPy random.noncentral_f() method returns the random samples from the noncentral F distribution.
Example
Python3
import numpy as np import matplotlib.pyplot as plt gfg = np.random.noncentral_f( 1.24 , 21 , 3 , 1000 ) count, bins, ignored = plt.hist(gfg, 50 , density = True ) plt.show() |
Output:
Syntax
Syntax: numpy.random.noncentral_f(dfnum, dfden, nonc, size=None)
Parameters:
- dfnum: Degrees of freedom in numerator.
- dfden: Degrees of freedom in denominator.
- nonc: Non-centrality parameter.
- size: Output shape.
Return: Return the random samples as numpy array.
How to Generate Random Samples from a noncentral F Distribution
To generate random samples from a noncentral F distribution we use the random.noncentral_f() method of NumPy library.
We have explained the method in the example below by plotting histogram using Matplot library.
Python3
# import numpy import numpy as np import matplotlib.pyplot as plt # Using noncentral_f() method gfg = np.random.noncentral_f( 10.23 , 12.13 , 3 , 10000 ) count, bins, ignored = plt.hist(gfg, 14 , density = True ) plt.show() |
Output:
Contact Us