code: def _test_rdp_gaussian_as_function_of_q(self):
      # Test for data-independent and data-dependent ranges over q.
      # The following corresponds to orders 1.1, 2.5, 32, 250
      # sigmas 1.5, 15, 1500, 15000.
      # Hand calculated -log(q0)s arranged in a 'sigma major' ordering.
      neglogq0s = [
          2.8,
          2.6,
          427,
          None,
          4.8,
          4.0,
          4.7,
          275,
          9.6,
          8.8,
          6.0,
          4,
          12,
          11.2,
          8.6,
          6.4,
      ]
      idx_neglogq0s = 0  # To iterate through neglogq0s.
      orders = [1.1, 2.5, 32, 250]
      sigmas = [1.5, 15, 1500, 15000]
      for sigma in sigmas:
          for order in orders:
              curr_neglogq0 = neglogq0s[idx_neglogq0s]
              idx_neglogq0s += 1
              if (
                  curr_neglogq0 is None
              ):  # sigma == 1.5 and order == 250:
                  continue
  
              rdp_at_q0 = pate.rdp_gaussian(
                  -curr_neglogq0, sigma, order
              )
  
              # Data-dependent range. (Successively halve the value of q.)
              logq_dds = -curr_neglogq0 - np.array(
                  [0, np.log(2), np.log(4), np.log(8)]
              )
              # Check that in q_dds, rdp is decreasing.
              for idx in range(len(logq_dds) - 1):
                  self.assertGreater(
                      pate.rdp_gaussian(logq_dds[idx], sigma, order),
                      pate.rdp_gaussian(
                          logq_dds[idx + 1], sigma, order
                      ),
                  )
  
              # Data-independent range.
              q_dids = np.exp(-curr_neglogq0) + np.array(
                  [0.1, 0.2, 0.3, 0.4]
              )
              # Check that in q_dids, rdp is constant.
              for q in q_dids:
                  self.assertEqual(
                      rdp_at_q0,
                      pate.rdp_gaussian(np.log(q), sigma, order),
                  )
  
file_path: privacy/research/pate_2018/core_test.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import sys
  import unittest
  import numpy
  import core
label_desc: Use image node_id 2 for calling the PateTest obj's underlying member method code with example usage: obj._test_rdp_gaussian_as_function_of_q() without return types