scipy.stats.chi()是chi連續隨機變量,已使用標準格式和一些形狀參數定義以完成其規格。
參數:
q :上下尾概率
x :分位數
loc :[可選]位置參數。默認值= 0
scale :[可選]比例參數。默認值= 1
size :[int型元組,可選]形狀或隨機變量。
moments :[可選]由字母['mvsk']組成; “ m” =均值,“ v” =方差,“ s” = Fisher的偏度,“ k” = Fisher的峰度。 (默認=“ MV”)。
結果:chi連續隨機變量
特別案例:
- chi(1,loc,scale)=半正態
- chi(2,0,scale)=瑞利
- chi(3,0,scale):麥克斯韋
代碼1:創建chi連續隨機變量
# importing scipy
from scipy.stats import chi
numargs = chi.numargs
[a] = [0.6, ] * numargs
rv = chi(a)
print ("RV : \n", rv)
輸出:
RV : <scipy.stats._distn_infrastructure.rv_frozen object at 0x000002948537C6D8>
代碼2:chi隨機變量和概率分布。
import numpy as np
quantile = np.arange (0.01, 1, 0.1)
# Random Variates
R = chi.rvs(a, scale = 2, size = 10)
print ("Random Variates : \n", R)
# PDF
R = chi.pdf(a, quantile, loc = 0, scale = 1)
print ("\nProbability Distribution : \n", R)
輸出:
Random Variates : [2.40483665 1.68478304 0.01664071 2.48977805 3.66286843 1.68463842 0.14434643 0.67812242 0.46190886 1.99973997] Probability Distribution : [0.01384193 0.14349716 0.25719966 0.35519439 0.43801475 0.50641521 0.56131243 0.60373433 0.63477687 0.65556791]
代碼3:圖形表示。
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))
輸出:
Distribution : 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. ]
代碼4:改變位置參數
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 5, 100)
# Varying positional arguments
y1 = chi.pdf(x, 1, 6)
y2 = chi.pdf(x, 1, 4)
plt.plot(x, y1, "*", x, y2, "r--")
輸出:
相關用法
- Python Scipy stats.f()用法及代碼示例
- Python Scipy stats.hmean()用法及代碼示例
- Python Scipy stats.halflogistic()用法及代碼示例
- Python Scipy stats.alpha()用法及代碼示例
- Python Scipy stats.halfnorm()用法及代碼示例
- Python Scipy stats.gompertz()用法及代碼示例
- Python Scipy stats.genlogistic()用法及代碼示例
- Python Scipy stats.fatiguelife()用法及代碼示例
- Python Scipy stats.fisk()用法及代碼示例
- Python Scipy stats.tmean()用法及代碼示例
- Python Scipy stats.genexpon()用法及代碼示例
- Python Scipy stats.genpareto()用法及代碼示例
- Python Scipy stats.mean()用法及代碼示例
- Python Scipy stats.gumbel_r()用法及代碼示例
- Python Scipy stats.gilbrat()用法及代碼示例
注:本文由純淨天空篩選整理自vishal3096大神的英文原創作品 scipy stats.chi() | Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。