code: Add laplace noise
This commit is contained in:
parent
62ea90ecf7
commit
dd3cff7b30
@ -68,6 +68,21 @@ def randomized_response(r, epsilon):
|
||||
return not r
|
||||
|
||||
|
||||
|
||||
def add_laplace_noise(value, sens, epsilon):
|
||||
'''
|
||||
Add random noise to a data value.
|
||||
|
||||
Parameteres:
|
||||
value - The value to add noise to.
|
||||
sens - The query function sensitivity.
|
||||
epsilon - The privacy budget.
|
||||
Returns:
|
||||
The value with the noise.
|
||||
'''
|
||||
return np.random.laplace(value, sens/epsilon)
|
||||
|
||||
|
||||
def draw_line(line, x, label, marker):
|
||||
axis_x = list(range(len(x)))
|
||||
# plt.xticks(axis_x, x)
|
||||
|
Loading…
Reference in New Issue
Block a user