Exemple #1
0
 def test_anonymize_proportion_single_many(self):
     expected_values = np.array([87.0586455, 87.2701297, 86.9451988])
     n = 10.0
     epsilon = 1.0
     anonymizer = DiffPrivLaplaceMechanism(epsilon)
     self.set_seed()
     anonymized = anonymizer.anonymize_proportion(87.0, n, size=3)
     np.testing.assert_almost_equal(anonymized, expected_values)
Exemple #2
0
 def test_anonymize_proportion_multiple(self):
     expected_values = np.array([87.0586455, 435.2701297])
     n = 10.0
     epsilon = 1.0
     anonymizer = DiffPrivLaplaceMechanism(epsilon)
     self.set_seed()
     anonymized = anonymizer.anonymize_proportion([87.0, 435.0], n)
     np.testing.assert_almost_equal(anonymized, expected_values)
Exemple #3
0
 def test_anonymize_proportion_single(self):
     expected_value = 87.05864551385037
     n = 10.0
     epsilon = 1.0
     anonymizer = DiffPrivLaplaceMechanism(epsilon)
     self.set_seed()
     anonymized = anonymizer.anonymize_proportion(87.0, n)
     np.testing.assert_almost_equal(anonymized, expected_value)