差分隱私的定義
數(shù)據(jù)的距離:
對(duì)于數(shù)據(jù)庫(kù) x ,它的第一范數(shù)為:
兩個(gè)數(shù)據(jù)庫(kù) x 和 y 的 距離是
。對(duì)于
表示數(shù)據(jù)庫(kù)x的大小堰氓。
表示數(shù)據(jù)x和y不同元素的個(gè)數(shù)
:
定義1:一個(gè)隨機(jī)算法M云茸,其值域范圍為,對(duì)于所有的
,和對(duì)于所有的x和y, 滿足
有:
當(dāng)時(shí)苗膝,其滿足
differential private
Laplace 機(jī)制
通過(guò)Laplace 函數(shù)可以個(gè)某個(gè)查詢f增加噪音,實(shí)現(xiàn)差分隱私
定義2:Laplace 分布植旧,隨機(jī)變量x滿足以下式子辱揭,其中a,b是參數(shù)
服從這個(gè)分布的隨機(jī)變量滿足
在利用Laplace 增加噪音實(shí)現(xiàn)差分隱私時(shí)问窃,需要將均值a,設(shè)置為0完沪,我們將此事的Laplace 密度函數(shù)記作
定義3:函數(shù)f 的?1敏感度域庇,對(duì)于一個(gè)函數(shù)
,有
定義4:Laplace 機(jī)制:對(duì)于函數(shù) ,Laplace 機(jī)制 M 被定義滿足如下:
其中是分別獨(dú)立地從
獲得的隨機(jī)變量
實(shí)驗(yàn)實(shí)現(xiàn)
Laplace 函數(shù)圖形:
import matplotlib.pyplot as plt
import numpy as np
def laplace_function(x, beta):
result = (1 / (2 * beta)) * np.e ** (-1 * (np.abs(x) / beta))
return result
# 在-5到5之間等間隔的取10000個(gè)數(shù)
x = np.linspace(-5, 5, 10000)
y1 = [laplace_function(x_, 0.5) for x_ in x]
y2 = [laplace_function(x_, 1) for x_ in x]
y3 = [laplace_function(x_, 2) for x_ in x]
plt.plot(x, y1, color='r', label='beta:0.5')
plt.plot(x, y2, color='g', label='beta:1')
plt.plot(x, y3, color='b', label='beta:2')
plt.title("Laplace distribution")
plt.legend()
plt.show()
Laplace 的分布
import matplotlib.pyplot as plt
import numpy as np
def count_zft():
i=0
sums=0
xx=np.random.laplace(0,1,100)
sums=sum(xx)
return sums
# print(sums)
if __name__=='__main__':
vec = list()
j=0;
while j<100000:
vec.append(count_zft())
j+=1
n, bins, patches = plt.hist(vec, 100, density=True, facecolor='g', alpha=0.75)
plt.xlabel('sum of nosiy')
plt.ylabel('Probability')
plt.title('')
plt.text(60, .025, r'$\mu=100,\ \sigma=15$')
plt.axis([-40, 40, 0, 0.06])
plt.grid(True)
plt.show()
100個(gè)噪音和的分布