指數(shù)分布(exponential distribution)和冪律分布(power-law distribution)有時(shí)看起來(lái)很是相似嘀掸,但實(shí)際上極為不同党瓮。我用python做了兩種分布的函數(shù)plotting晃危,方便直觀理解。可以看到妄荔,兩種函數(shù)轉(zhuǎn)化為雙對(duì)數(shù)形式(這里我用的math.log()是自然對(duì)數(shù)ln)后圖像差異非常明顯。
注釋里我給出了幾個(gè)圖分別對(duì)應(yīng)的解析式谍肤,另外注意因?yàn)檫@里是用離散的點(diǎn)集近似啦租,相當(dāng)于對(duì)分布函數(shù)曲線的采樣,所以可以得到一個(gè)power-law的數(shù)值mean荒揣,數(shù)學(xué)上power-law的均值存在須滿(mǎn)足一些條件篷角。
import matplotlib.pyplot as plt
import math
%matplotlib inline
# exponential distribution
# y = c ** x
x = list(range(1,100))
c = 0.9
y = [c**i for i in x]
print('mean: {}'.format(sum(y)/len(y))) # exponent has mean which equals to the exponent c
plt.plot(x,y)
plt.show()
mean: 0.09090640793950629
# log-log exponential distribution
# y_ln = ln(c) * exp(x_ln)
x_ln = [math.log(i) for i in x]
y_ln = [math.log(i) for i in y]
plt.plot(x_ln,y_ln)
plt.show()
# power-law distribution
# y = x ** c
x = list(range(1,100))
c = -2
y = [i**c for i in x]
print('mean: {}'.format(sum(y)/len(y))) # power-law has no mean
plt.plot(x,y)
plt.show()
mean: 0.016513978789746385
# log-log power-law distribution
# y_ln = c * x_ln
x_ln = [math.log(i) for i in x]
y_ln = [math.log(i) for i in y]
plt.plot(x_ln,y_ln)
plt.show()