scipy stats.frechet_l() | Python
scipy.stats.frechet_l()是一个 Frechet 左(或 Weibull 最大值)连续随机变量,使用标准格式和一些形状参数定义以完成其规范。
Parameters :
-> q : lower and upper tail probability
-> a : shape parameters
-> 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 : Frechet left continuous random variable
代码 #1:创建 Frechet 左连续随机变量
from scipy.stats import frechet_l
numargs = frechet_l .numargs
[a] = [0.7, ] * numargs
rv = frechet_l (a)
print ("RV : \n", rv)
输出 :
RV :
代码#2:Frechet 左随机变量和概率分布。
import numpy as np
quantile = np.arange (0.01, 1, 0.1)
# Random Variates
R = frechet_l.rvs(a, scale = 2, size = 10)
print ("Random Variates : \n", R)
# PDF
R = frechet_l.pdf(a, quantile, loc = 0, scale = 1)
print ("\nProbability Distribution : \n", R)
输出 :
Random Variates :
[-4.66775585e-02 -3.75425255e+00 -2.32248407e-01 -1.20807347e-03
-6.26373883e+00 -1.14007755e+00 -5.09499683e+00 -4.18191271e-01
-4.33720753e+00 -1.05442843e+00]
Probability Distribution :
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
代码#3:改变位置参数
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 5, 100)
# Varying positional arguments
y1 = frechet_l.pdf(x, 1, 3)
y2 = frechet_l.pdf(x, 1, 4)
plt.plot(x, y1, "*", x, y2, "r--")
输出 :