示例#1
0
    def test_compute_dp_count(self):
        params = dp_computations.MeanVarParams(
            eps=0.5,
            delta=1e-10,
            min_value=0,
            max_value=0,
            max_partitions_contributed=1,
            max_contributions_per_partition=1,
            noise_kind=NoiseKind.LAPLACE)
        l0_sensitivity = params.l0_sensitivity()
        linf_sensitivity = params.max_contributions_per_partition

        # Laplace Mechanism
        l1_sensitivity = dp_computations.compute_l1_sensitivity(
            l0_sensitivity, linf_sensitivity)
        results = [
            dp_computations.compute_dp_count(count=10, dp_params=params)
            for _ in range(N_ITERATIONS)
        ]
        self._test_laplace_noise(results, 10, params.eps, l1_sensitivity)

        # Gaussian Mechanism
        params.noise_kind = NoiseKind.GAUSSIAN
        l2_sensitivity = dp_computations.compute_l2_sensitivity(
            l0_sensitivity, linf_sensitivity)
        results = [
            dp_computations.compute_dp_count(count=10, dp_params=params)
            for _ in range(N_ITERATIONS)
        ]
        self._test_gaussian_noise(results, 10, params.eps, params.delta,
                                  l2_sensitivity)
示例#2
0
 def compute_metrics(self, accumulator: AccumulatorType) -> dict:
     return {
         'privacy_id_count':
         dp_computations.compute_dp_count(accumulator,
                                          self._params.scalar_noise_params)
     }
示例#3
0
 def compute_metrics(self) -> float:
     return dp_computations.compute_dp_count(self._count,
                                             self._params.mean_var_params)
示例#4
0
 def compute_metrics(self, count: AccumulatorType) -> dict:
     return {
         'count':
         dp_computations.compute_dp_count(count,
                                          self._params.scalar_noise_params)
     }