diff --git a/code/lib/exp_mech.py b/code/lib/exp_mech.py index cd298fb..60bab2b 100644 --- a/code/lib/exp_mech.py +++ b/code/lib/exp_mech.py @@ -11,33 +11,34 @@ from matplotlib import pyplot as plt import time -''' - The scoring function. - - Parameters: - data - The data. - option - The option to evaluate. - Returns: - The score for the option. -''' def score(data, option): + ''' + The scoring function. + + Parameters: + data - The data. + option - The option to evaluate. + Returns: + The score for the option. + ''' return (option.sum() - data.sum()) + # return lmdk_lib.get_norm(data, option) -''' - The exponential mechanism. - - Parameters: - x - The data. - R - The possible outputs. - u - The scoring function. - delta - The sensitivity of the scoring function. - epsilon - The privacy budget. - Returns: - res - A randomly sampled output. - pr - The PDF of all possible outputs. -''' def exponential(x, R, u, delta, epsilon): + ''' + The exponential mechanism. + + Parameters: + x - The data. + R - The possible outputs. + u - The scoring function. + delta - The sensitivity of the scoring function. + epsilon - The privacy budget. + Returns: + res - A randomly sampled output. + pr - The PDF of all possible outputs. + ''' # Calculate the score for each element of R scores = [u(x, r) for r in R] # Normalize the scores between 0 and 1 diff --git a/rslt/bgt_cmp/Copenhagen-sel.pdf b/rslt/bgt_cmp/Copenhagen-sel.pdf index b81c1c1..9736b4d 100644 Binary files a/rslt/bgt_cmp/Copenhagen-sel.pdf and b/rslt/bgt_cmp/Copenhagen-sel.pdf differ diff --git a/rslt/bgt_cmp/HUE-sel.pdf b/rslt/bgt_cmp/HUE-sel.pdf index 5f75788..05a381e 100644 Binary files a/rslt/bgt_cmp/HUE-sel.pdf and b/rslt/bgt_cmp/HUE-sel.pdf differ diff --git a/rslt/bgt_cmp/T-drive-sel.pdf b/rslt/bgt_cmp/T-drive-sel.pdf new file mode 100644 index 0000000..1832b87 Binary files /dev/null and b/rslt/bgt_cmp/T-drive-sel.pdf differ