docstr: Tests batch of 1-Factor model with constant parameters.
docstr_tok: ["Tests","batch","of","1-Factor","model","with","constant","parameters","."]
code: def test_zcb_variance_batch_1_factor(self):
      """Tests batch of 1-Factor model with constant parameters."""
      num_samples = 100000
      for dtype in [tf.float64]:
          curve_times = np.array([0.0, 0.5, 1.0, 5.0, 10.0])
          times = np.array([0.1, 0.5, 1.0, 3])
          process = tff.models.hjm.QuasiGaussianHJM(
              dim=1,
              mean_reversion=self.mean_reversion_batch_1_factor,
              volatility=self.volatility_batch_1_factor,
              initial_discount_rate_fn=self.instant_forward_rate_batch,
              dtype=dtype,
          )
          # generate zero coupon paths
          paths, _, _ = process.sample_discount_curve_paths(
              times,
              curve_times=curve_times,
              num_samples=num_samples,
              time_step=0.1,
              random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
              seed=[1, 2],
              skip=1000000,
          )
          self.assertEqual(paths.dtype, dtype)
          paths = self.evaluate(paths)
          self.assertAllEqual(paths.shape, [2, num_samples, 5, 4])
          sampled_std = tf.math.reduce_std(tf.math.log(paths), axis=1)
          for i in range(2):
              for tidx in range(4):
                  true_std = self.true_zcb_std(
                      times[tidx],
                      curve_times + times[tidx],
                      self.volatility_batch_1_factor[i][0],
                      self.mean_reversion_batch_1_factor[i][0],
                  )
                  with self.subTest(
                      "Batch_{}_time_index{}".format(i, tidx)
                  ):
                      self.assertAllClose(
                          sampled_std[i, :, tidx],
                          true_std,
                          rtol=5e-4,
                          atol=5e-4,
                      )
  
file_path: tf-quant-finance/tf_quant_finance/models/hjm/quasi_gaussian_hjm_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
label_desc: Use image node_id 5 for calling the HJMModelTest obj's underlying member method code with example usage: obj.test_zcb_variance_batch_1_factor() without return types