📌  相关文章
📜  scipPy stats.anglit() | Python

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

scipPy stats.anglit() | Python

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

代码#1:创建有角度的连续随机变量

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

输出 :

RV :  

代码#2:anglit 随机变量和概率分布函数。

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

输出 :

Random Variates : 
 [-0.73702502 -1.38273136  0.39618481 -0.48434091 -0.85635192 -0.36402882
 -0.21016273  0.53857078  0.96918022 -0.84314795]

Probability Distribution : 
 [0.99980001 0.97589745 0.91308894 0.81387846 0.68222121 0.52336595
 0.34364575 0.15022547 0.         0.        ]
 

代码#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 : 
 [0.         0.01602853 0.03205707 0.0480856  0.06411414 0.08014267
 0.0961712  0.11219974 0.12822827 0.14425681 0.16028534 0.17631387
 0.19234241 0.20837094 0.22439948 0.24042801 0.25645654 0.27248508
 0.28851361 0.30454214 0.32057068 0.33659921 0.35262775 0.36865628
 0.38468481 0.40071335 0.41674188 0.43277042 0.44879895 0.46482748
 0.48085602 0.49688455 0.51291309 0.52894162 0.54497015 0.56099869
 0.57702722 0.59305576 0.60908429 0.62511282 0.64114136 0.65716989
 0.67319843 0.68922696 0.70525549 0.72128403 0.73731256 0.7533411
 0.76936963 0.78539816]

代码#4:改变位置参数

import matplotlib.pyplot as plt
import numpy as np
  
x = np.linspace(0, 5, 100)
  
# Varying positional arguments
y1 = anglit.pdf(x, 1, 6)
y2 = anglit.pdf(x, 1, 4)
plt.plot(x, y1, "*", x, y2, "r--")

输出 :