Esempio n. 1
0
 def test_anonymize_min_with_budget_multiple(self):
     expected_values = np.array([87.5864551, 437.701297])
     epsilon = 1.0
     self.set_seed()
     anonymized = DiffPrivLaplaceMechanism.anonymize_min_with_budget(
         [87.0, 435.0], epsilon)
     np.testing.assert_almost_equal(anonymized, expected_values)
Esempio n. 2
0
 def test_anonymize_min_with_budget_single(self):
     expected_value = 87.58645513850368
     epsilon = 1.0
     self.set_seed()
     anonymized = DiffPrivLaplaceMechanism.anonymize_min_with_budget(
         87.0, epsilon)
     np.testing.assert_almost_equal(anonymized, expected_value)
Esempio n. 3
0
 def test_anonymize_min_with_budget_single_many(self):
     expected_values = np.array([87.5864551, 89.701297, 86.4519884])
     epsilon = 1.0
     self.set_seed()
     anonymized = DiffPrivLaplaceMechanism.anonymize_min_with_budget(
         87.0, epsilon, size=3)
     np.testing.assert_almost_equal(anonymized, expected_values)
Esempio n. 4
0
    def min(cls, data, epsilon, axis=None):
        """
        Performs the min operation and anonymizes the value(s) using the provided
        privacy budget.

        Parameters
        ----------
        data : list|ndarray
            The data to retrieve the min value(s) from.
        epsilon : float
            The privacy budget.
        [axis] : int|tuple
            Axis or tuple of axes along which to obtain the min value(s).

        Returns
        -------
        float|ndarray
            The anonymized min value(s).

        """
        value = np.min(data, axis=axis)
        anonymized = DiffPrivLaplaceMechanism.anonymize_min_with_budget(
            value, epsilon)
        return anonymized