Exemple #1
0
 def test_anonymize_variance_single(self):
     expected_value = 133.45311152087612
     lower = 10.0
     upper = 99.0
     n = 100.0
     epsilon = 1.0
     anonymizer = DiffPrivLaplaceMechanism(epsilon)
     self.set_seed()
     anonymized = anonymizer.anonymize_variance(87.0, lower, upper, n)
     np.testing.assert_almost_equal(anonymized, expected_value)
Exemple #2
0
 def test_anonymize_variance_multiple(self):
     expected_values = np.array([133.4531115, 648.969738])
     lower = 10.0
     upper = 99.0
     n = 100.0
     epsilon = 1.0
     anonymizer = DiffPrivLaplaceMechanism(epsilon)
     self.set_seed()
     anonymized = anonymizer.anonymize_variance([87.0, 435.0], lower, upper,
                                                n)
     np.testing.assert_almost_equal(anonymized, expected_values)
Exemple #3
0
 def test_anonymize_variance_single_many(self):
     expected_values = np.array([133.4531115, 300.969738, 43.5919983])
     lower = 10.0
     upper = 99.0
     n = 100.0
     epsilon = 1.0
     anonymizer = DiffPrivLaplaceMechanism(epsilon)
     self.set_seed()
     anonymized = anonymizer.anonymize_variance(87.0,
                                                lower,
                                                upper,
                                                n,
                                                size=3)
     np.testing.assert_almost_equal(anonymized, expected_values)