宜兴网站设计,正规开网店咨询,为某企业策划一次网络营销活动,硅胶 技术支持 东莞网站建设统计学是数据科学和分析的基石。 它为我们提供了一个强大的工具箱来客观地回答复杂的问题。 然而#xff0c;许多我们最喜欢的统计工具在应用于特定类别的数据#xff08;幂律#xff09;时变得毫无用处。
统计中的幂函数分布
scipy.stats.powerlaw() 是幂函数连续随机变量…统计学是数据科学和分析的基石。 它为我们提供了一个强大的工具箱来客观地回答复杂的问题。 然而许多我们最喜欢的统计工具在应用于特定类别的数据幂律时变得毫无用处。
统计中的幂函数分布
scipy.stats.powerlaw() 是幂函数连续随机变量。它作为 rv_continuous 类的实例从泛型方法继承。它使用特定于此特定发行版的详细信息来完成方法。
代码片段-1创建幂函数连续随机变量
# importing library from scipy.stats import powerlaw numargs powerlaw.numargs
a, b 4.32, 3.18
rv powerlaw(a, b) print (RV : \n, rv) 输出
RV : scipy.stats._distn_infrastructure.rv_frozen object at 0x000002A9D8295B48代码片段-2幂函数连续变量和概率分布
import numpy as np
quantile np.arange (0.01, 1, 0.1) # Random Variates
R powerlaw.rvs(a, b)
print (Random Variates : \n, R) # PDF
R powerlaw.pdf(a, b, quantile)
print (\nProbability Distribution : \n, R)
输出
Random Variates : 3.860143037448123Probability Distribution : [0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]代码片段-3图形表示
import numpy as np
import matplotlib.pyplot as plt distribution np.linspace(0, np.minimum(rv.dist.b, 3))
print(Distribution : \n, distribution) plot plt.plot(distribution, rv.pdf(distribution))
输出
Distribution : [0. 0.02040816 0.04081633 0.06122449 0.08163265 0.102040820.12244898 0.14285714 0.16326531 0.18367347 0.20408163 0.22448980.24489796 0.26530612 0.28571429 0.30612245 0.32653061 0.346938780.36734694 0.3877551 0.40816327 0.42857143 0.44897959 0.469387760.48979592 0.51020408 0.53061224 0.55102041 0.57142857 0.591836730.6122449 0.63265306 0.65306122 0.67346939 0.69387755 0.714285710.73469388 0.75510204 0.7755102 0.79591837 0.81632653 0.836734690.85714286 0.87755102 0.89795918 0.91836735 0.93877551 0.959183670.97959184 1. ]代码片段-4不同的位置参数
import matplotlib.pyplot as plt
import numpy as np x np.linspace(0, 5, 100) # Varying positional arguments
y1 powerlaw .pdf(x, 1, 3, 5)
y2 powerlaw .pdf(x, 1, 4, 4)
plt.plot(x, y1, *, x, y2, r--)
验证厚尾数据符合幂定律示例
在这里我们将使用Python 库确定数据集是否真正遵循幂律分布。
Python验证人工数据
Python验证现实数据
源代码
参阅 - 亚图跨际