docstr: Compare the percentiles of distributed and centralized Skellam.
  
  The test creates a large zero-vector with shape [num_trials, num_users] to
  be processed with the distributed Skellam noise stddev=1. The result is
  summed over the num_users dimension. The centralized result is produced by
  adding noise to a zero vector [num_trials] with stddev = 1*sqrt(num_users).
  Both results are evaluated to match percentiles (25, 50, 75).
docstr_tok: ["Compare","the","percentiles","of","distributed","and","centralized","Skellam",".","The","test","creates","a","large","zero-vector","with","shape","[","num_trials",",","num_users","]","to","be","processed","with","the","distributed","Skellam","noise","stddev=1",".","The","result","is","summed","over","the","num_users","dimension",".","The","centralized","result","is","produced","by","adding","noise","to","a","zero","vector","[","num_trials","]","with","stddev","=","1","*","sqrt","(","num_users",")",".","Both","results","are","evaluated","to","match","percentiles","(","25",",","50",",","75",")","."]
code: def test_compare_centralized_distributed_skellam(self):
      """Compare the percentiles of distributed and centralized Skellam.
  
      The test creates a large zero-vector with shape [num_trials, num_users] to
      be processed with the distributed Skellam noise stddev=1. The result is
      summed over the num_users dimension. The centralized result is produced by
      adding noise to a zero vector [num_trials] with stddev = 1*sqrt(num_users).
      Both results are evaluated to match percentiles (25, 50, 75).
      """
  
      num_trials = 10000
      num_users = 100
      record = tf.zeros([num_trials], dtype=tf.int32)
      local_stddev = 1.0
      query = distributed_skellam_query.DistributedSkellamSumQuery(
          l1_norm_bound=10.0,
          l2_norm_bound=10,
          local_stddev=local_stddev,
      )
      distributed_noised = tf.zeros([num_trials], dtype=tf.int32)
      for _ in range(num_users):
          query_result, _ = test_utils.run_query(query, [record])
          distributed_noised += query_result
  
      def add_noise(v, stddev):
          lam = stddev**2 / 2
  
          noise_poisson1 = tf.random.poisson(
              lam=lam, shape=tf.shape(v), dtype=v.dtype
          )
          noise_poisson2 = tf.random.poisson(
              lam=lam, shape=tf.shape(v), dtype=v.dtype
          )
          res = v + (noise_poisson1 - noise_poisson2)
          return res
  
      record_centralized = tf.zeros([num_trials], dtype=tf.int32)
      centralized_noised = add_noise(
          record_centralized, local_stddev * np.sqrt(num_users)
      )
  
      tolerance = 5
      self.assertAllClose(
          tfp.stats.percentile(distributed_noised, 50.0),
          tfp.stats.percentile(centralized_noised, 50.0),
          atol=tolerance,
      )
      self.assertAllClose(
          tfp.stats.percentile(distributed_noised, 75.0),
          tfp.stats.percentile(centralized_noised, 75.0),
          atol=tolerance,
      )
      self.assertAllClose(
          tfp.stats.percentile(distributed_noised, 25.0),
          tfp.stats.percentile(centralized_noised, 25.0),
          atol=tolerance,
      )
  
file_path: privacy/tensorflow_privacy/privacy/dp_query/distributed_skellam_query_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow
  from tensorflow_privacy.privacy.dp_query import distributed_skellam_query
  from tensorflow_privacy.privacy.dp_query import test_utils
  import tensorflow_probability
label_desc: Use image node_id 7 for calling the DistributedSkellamQueryTest obj's underlying member method code with example usage: obj.test_compare_centralized_distributed_skellam() and returns: res