From 1a464d2fb8ff4a1d66674eb7750dfcfd1b56e265 Mon Sep 17 00:00:00 2001 From: Manos Date: Wed, 29 Sep 2021 02:32:22 +0200 Subject: [PATCH] lmdk_bgt: Added Skip --- code/lib/lmdk_bgt.py | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/code/lib/lmdk_bgt.py b/code/lib/lmdk_bgt.py index 10d6b20..07474b3 100644 --- a/code/lib/lmdk_bgt.py +++ b/code/lib/lmdk_bgt.py @@ -374,6 +374,36 @@ def skip(seq, lmdks, epsilon): return rls_data, bgts +def skip_cont(seq, lmdks, epsilon): + ''' + Skip landmarks. + + Parameters: + seq - The point sequence. + lmdks - The landmarks. + epsilon - The available privacy budget. + Returns: + rls_data - The perturbed data. + bgts - The privacy budget allocation. + ''' + # Event-level budget allocation + bgts = np.array(len(seq)*[epsilon]) + # Released + rls_data = [None]*len(seq) + for i, p in enumerate(seq): + # Check if current point is a landmark + r = p[2] in lmdks + # Add noise + o = lmdk_lib.randomized_response(r, bgts[i]) + if r: + if i > 0: + # Approximate with previous + o = rls_data[i - 1][1] + bgts[i] = 0 + rls_data[i] = [r, o] + return rls_data, bgts + + def sample(seq, lmdks, epsilon): ''' Publish randomly. @@ -602,5 +632,4 @@ def mae_cont(o): # Check if original differs from final if p[0] != p[1]: mae += 1/len(o) - print(mae) return mae