📜  scipy stats.bradford() | Python

📅  最后修改于: 2022-05-13 01:54:49.662000             🧑  作者: Mango

scipy stats.bradford() | Python

scipy.stats.bradford()是一个 bradford 连续随机变量,使用标准格式和一些形状参数定义以完成其规范。

代码 #1:创建布拉德福德连续随机变量

# importing scipy
from scipy.stats import bradford
  
numargs = bradford.numargs
[a] = [0.6, ] * numargs
rv = bradford(a)
  
print ("RV : \n", rv)

输出 :

RV : 
 

代码 #2: bradford 随机变量和概率分布

import numpy as np
quantile = np.arange (0.01, 1, 0.1)
   
# Random Variates
R = bradford.rvs(a, scale = 2,  size = 10)
print ("Random Variates : \n", R)
  
# PDF
R = bradford.pdf(quantile, a, loc = 0, scale = 1)
print ("\nProbability Distribution : \n", R)

输出 :

Random Variates : 
 [0.30727583 0.22129839 0.27130072 0.19795865 1.66069665 1.93938843
 0.43435698 0.16437308 0.91592562 1.95369029]

Probability Distribution : 
 [1.26897205 1.19754774 1.13373525 1.07637933 1.02454726 0.97747771
 0.93454311 0.89522152 0.85907529 0.82573473]

代码#3:图形表示。

import numpy as np
import matplotlib.pyplot as plt
  
distribution = np.linspace(0, np.maximum(rv.dist.b, 5))
print ("Distribution : \n", distribution)
  
plot = plt.plot(distribution, rv.pdf(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.        ]