日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 综合教程 >内容正文

综合教程

无标度网络-幂律分布

發(fā)布時(shí)間:2024/9/19 综合教程 28 生活家
生活随笔 收集整理的這篇文章主要介紹了 无标度网络-幂律分布 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

參考鏈接https://ask.csdn.net/questions/365756

今天一直在找關(guān)于冪律分布的驗(yàn)證相關(guān)資料,很多都是只言片語,這個(gè)圖首先解釋了冪律分布的定義

2.然后,https://www.douban.com/group/topic/69712255/ 真正實(shí)踐去驗(yàn)證的時(shí)候,先在python環(huán)境下安裝powerlaw包,然后這個(gè)鏈接內(nèi)容告訴我們具體怎么應(yīng)用這個(gè)包,對(duì)每行代碼的解釋真心很詳細(xì)!powerlaw.Fit擬合冪律分布

# -*- coding: utf-8 -*-
import numpy as np

from matplotlib.pylab import plt

import powerlaw

#打開數(shù)據(jù)包------------------------------------------------------------

data=np.loadtxt('C:/Users/peterduus/degree.txt')

#用numpy的loadtxt()方法把文本數(shù)據(jù)讀入二維數(shù)組---------------------------

fit=powerlaw.Fit(data,discrete=True)

print 'xmin =',fit.xmin

print 'alpha =',fit.power_law.alpha

print 'sigma =',fit.power_law.sigma

print 'D =',fit.power_law.D

#擬合冪律,放到名為fit的對(duì)象中。網(wǎng)絡(luò)度是離散的,所以要用discrete=True。

#是不是離散型數(shù)據(jù),可以用fit.power_law.discrete來查看。

#計(jì)算fit的最小界值。

#計(jì)算fit的alpha值。根據(jù)所遵循公式,alpha是冪指數(shù),即P(x)是x的-alpha次方。
也就是我們想要的參數(shù)值了,參考文獻(xiàn)中講到是通過最大似然估計(jì)得到的。一般冪律分布的該參數(shù)范圍在2-3是很典型的值。
#sigma是alpha的標(biāo)準(zhǔn)差。

#注意看冪律區(qū)間如果占據(jù)總區(qū)間很小部分,那這種擬合是沒有意義的。

R1,p1=fit.distribution_compare('power_law','exponential')

R2,p2=fit.distribution_compare('power_law','lognormal')

R3,p3=fit.distribution_compare('power_law', 'stretched_exponential')

R4,p4=fit.distribution_compare('power_law', 'truncated_power_law')

R12,p12=fit2.distribution_compare('power_law','exponential')

R22,p22=fit2.distribution_compare('power_law','lognormal')

R32,p32=fit2.distribution_compare('power_law', 'stretched_exponential')

R42,p42=fit2.distribution_compare('power_law', 'truncated_power_law')

R52,p52=fit2.distribution_compare('exponential', 'truncated_power_law')

print 'power_law vs. ','exponential ',R1,p1

print 'power_law vs. ','lognormal ',R2,p2

print 'power_law vs. ', 'stretched_exponential ',R3,p3

print 'power_law vs. ', 'truncated_power_law ',R4,p4

print '
'

print 'power_law vs. ','exponential ',R12,p12

print 'power_law vs. ', 'truncated_power_law ',R42,p42

print 'exponential vs. ', 'truncated_power_law ',R52,p52

#R是似然比,正值表示前者比后者更契合數(shù)據(jù),

#p是兩模型的差異是否具有顯著性,即用R所做的比較結(jié)果是否有統(tǒng)計(jì)學(xué)意義

3.文章中還用到ks檢驗(yàn),暫時(shí)還沒明白如何用代碼進(jìn)行檢驗(yàn),有待補(bǔ)充!

總結(jié)

以上是生活随笔為你收集整理的无标度网络-幂律分布的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。