scipy.stats.chi2() | Python Last Updated : 20 Mar, 2019 Comments Improve Suggest changes Like Article Like Report scipy.stats.chi2() is an chi square continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : q : lower and upper tail probability x : quantiles loc : [optional]location parameter. Default = 0 scale : [optional]scale parameter. Default = 1 size : [tuple of ints, optional] shape or random variates. moments : [optional] composed of letters [‘mvsk’]; 'm' = mean, 'v' = variance, 's' = Fisher's skew and 'k' = Fisher's kurtosis. (default = 'mv'). Results : chi squared continuous random variable Code #1 : Creating chi squared continuous random variable Python3 # importing scipy from scipy.stats import chi2 numargs = chi2.numargs [a] = [0.6, ] * numargs rv = chi2(a) print ("RV : \n", rv) Output : RV : <scipy.stats._distn_infrastructure.rv_frozen object at 0x0000029485196DD8> Code #2 : chi2 random variates and probability distribution function. Python3 1== import numpy as np quantile = np.arange (0.01, 1, 0.1) # Random Variates R = chi2.rvs(a, scale = 2, size = 10) print ("Random Variates : \n", R) # PDF R = chi2.pdf(a, quantile, loc = 0, scale = 1) print ("\nProbability Distribution : \n", R) Output : Random Variates : [6.20115012e-01 4.82717678e-01 1.43760444e-02 1.19755537e+00 3.00093606e-05 6.11268950e-01 5.99940774e-01 3.20509994e-01 1.94220599e-01 6.63225404e-01] Probability Distribution : [0.00615404 0.06544849 0.12034254 0.1704933 0.21568622 0.25581903 0.29088625 0.32096438 0.34619796 0.36678666] Code #3 : Graphical Representation. Python3 import numpy as np import matplotlib.pyplot as plt distribution = np.linspace(0, np.minimum(rv.dist.b, 5)) print("Distribution : \n", distribution) plot = plt.plot(distribution, rv.pdf(distribution)) Output : Distribution : [0. 0.10204082 0.20408163 0.30612245 0.40816327 0.51020408 0.6122449 0.71428571 0.81632653 0.91836735 1.02040816 1.12244898 1.2244898 1.32653061 1.42857143 1.53061224 1.63265306 1.73469388 1.83673469 1.93877551 2.04081633 2.14285714 2.24489796 2.34693878 2.44897959 2.55102041 2.65306122 2.75510204 2.85714286 2.95918367 3.06122449 3.16326531 3.26530612 3.36734694 3.46938776 3.57142857 3.67346939 3.7755102 3.87755102 3.97959184 4.08163265 4.18367347 4.28571429 4.3877551 4.48979592 4.59183673 4.69387755 4.79591837 4.89795918 5. ] Code #4 : Varying Positional Arguments Python3 1== import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 5, 100) # Varying positional arguments y1 = chi2.pdf(x, 1, 6) y2 = chi2.pdf(x, 1, 4) plt.plot(x, y1, "*", x, y2, "r--") Output : Comment More infoAdvertise with us Next Article scipy.stats.chi2() | Python V vishal3096 Follow Improve Article Tags : Python Python scipy-stats-functions Python-scipy Practice Tags : python Similar Reads scipy stats.chi() | Python scipy.stats.chi() is an chi continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : q : lower and upper tail probability x : quantiles loc : [optional] location parameter. Default = 0 scale : [optional] scale parameter. 2 min read scipy stats.cosine() | Python scipy.stats.cosine() is an cosine continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : q : lower and upper tail probability x : quantiles loc : [optional]location parameter. Default = 0 scale : [optional]scale paramet 2 min read scipy stats.cauchy() | Python scipy.stats.cauchy() is an cauchy continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : q : lower and upper tail probability x : quantiles loc : [optional]location parameter. Default = 0 scale : [optional]scale paramet 2 min read scipy stats.f() | Python scipy.stats.f() is an F continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : q : lower and upper tail probability a, b : shape parameters x : quantiles loc : [optional] location parameter. Default = 0 scale : [optiona 2 min read scipy stats.fisk() | Python scipy.stats.fisk() is an fisk continuous random variable. It is also known as the log-logistic distribution, and equals the Burr distribution with d == 1 and is defined with a standard format and some shape parameters to complete its specification. Parameters : q : lower and upper tail probability x 2 min read sciPy stats.alpha() | Python scipy.stats.alpha() is an alpha continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : q : lower and upper tail probability x : quantiles a : shape parameter loc : [optional] location parameter. Default = 0 scale : [opt 1 min read scipy stats.burr() | Python scipy.stats.burr() is an burr continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : q : lower and upper tail probability a, b : shape parameters x : quantiles loc : [optional] location parameter. Default = 0 scale : [o 2 min read scipy stats.beta() | Python The scipy.stats.beta() is a beta continuous random variable that is defined with a standard format and some shape parameters to complete its specification. f(x,α,β)=(Î(α+β)xαâ1(1âx)βâ1â)/Î(α)Î(β) where: α>0 and β>0β>0 are the shape parameters of the Beta distribution.Î Gamma is the Gamma fu 2 min read scipy stats.gilbrat() | Python scipy.stats.gilbrat() is an Gilbrat continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : -> q : lower and upper tail probability -> x : quantiles -> loc : [optional]location parameter. Default = 0 -> scale 2 min read scipy stats.gamma() | Python scipy.stats.gamma() is an gamma continuous random variable that is defined with a standard format and some shape parameters to complete its specification. Parameters : -> q : lower and upper tail probability -> x : quantiles -> loc : [optional]location parameter. Default = 0 -> scale : [ 2 min read Like