docstr: Tests short rate and discount factor simulations.
docstr_tok: ["Tests","short","rate","and","discount","factor","simulations","."]
code: def test_correctness_rate_df_sims(
      self,
      dim,
      mr,
      vol,
      corr,
      vol_jumps,
      vol_values,
      num_time_steps,
      dtype,
  ):
      """Tests short rate and discount factor simulations."""
      if vol is None:
          vol = tff.math.piecewise.PiecewiseConstantFunc(
              vol_jumps, vol_values, dtype=dtype
          )
      time_step = None if num_time_steps else 0.1
      num_samples = 100000
      process = tff.models.hjm.GaussianHJM(
          dim=dim,
          mean_reversion=mr,
          volatility=vol,
          initial_discount_rate_fn=self.instant_forward_rate,
          corr_matrix=corr,
          dtype=dtype,
      )
      times = np.array([0.1, 0.5, 1.0, 2.0])
      paths, df, _, _ = process.sample_paths(
          times,
          num_samples=num_samples,
          time_step=time_step,
          num_time_steps=num_time_steps,
          random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
          seed=[1, 2],
          skip=1000000,
      )
      if dtype is not None:
          with self.subTest("Dtype"):
              self.assertEqual(paths.dtype, dtype)
      paths = self.evaluate(paths)
      df = self.evaluate(df)
      with self.subTest("ShapePaths"):
          self.assertAllEqual(paths.shape, [num_samples, 4])
      with self.subTest("ShapeDiscountFactors"):
          self.assertAllEqual(df.shape, [num_samples, 4])
      discount_mean = np.mean(df, axis=0)
      expected_mean = np.exp(-0.01 * times)
      with self.subTest("DiscountMean"):
          self.assertAllClose(
              discount_mean, expected_mean, rtol=1e-3, atol=1e-3
          )
  
file_path: tf-quant-finance/tf_quant_finance/models/hjm/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 2 for calling the GaussianHJMModelTest obj's underlying member method code with example usage: obj.test_correctness_rate_df_sims(dim, mr, vol, corr, vol_jumps, vol_values, num_time_steps, dtype) without return types