docstr: Tests path properties for 2-dimentional Ito process.
docstr_tok: ["Tests","path","properties","for","2-dimentional","Ito","process","."]
code: def test_halton_sample_paths_2d(self, watch_params):
      """Tests path properties for 2-dimentional Ito process."""
      # We construct the following Ito processes.
      # dX_1 = mu_1 sqrt(t) dt + s11 dW_1 + s12 dW_2
      # dX_2 = mu_2 sqrt(t) dt + s21 dW_1 + s22 dW_2
      # mu_1, mu_2 are constants.
      # s_ij = a_ij t + b_ij
      # For this process expected value at time t is (x_0)_i + 2/3 * mu_i * t^1.5.
      dtype = tf.float64
      num_samples = 10000
      times = np.array([0.1, 0.21, 0.32])
      x0 = np.array([0.1, -1.1])
      mu = np.array([0.2, 0.7])
      a = np.array([[0.4, 0.1], [0.3, 0.2]])
      b = np.array([[0.33, -0.03], [0.21, 0.5]])
  
      def sample_fn(mu, a, b):
          mu = tf.convert_to_tensor(mu, dtype=dtype)
          a = tf.convert_to_tensor(a, dtype=dtype)
          b = tf.convert_to_tensor(b, dtype=dtype)
  
          def drift_fn(t, x):
              return mu * tf.sqrt(t) * tf.ones_like(x, dtype=t.dtype)
  
          def vol_fn(t, x):
              del x
              return (a * t + b) * tf.ones([2, 2], dtype=t.dtype)
  
          if watch_params:
              watch_params_tf = [a, b]
          else:
              watch_params_tf = None
          return euler_sampling.sample(
              dim=2,
              drift_fn=drift_fn,
              volatility_fn=vol_fn,
              times=times,
              num_samples=num_samples,
              initial_state=x0,
              random_type=tff.math.random.RandomType.HALTON,
              time_step=0.01,
              seed=12134,
              skip=100,
              watch_params=watch_params_tf,
              dtype=dtype,
          )
  
      paths = self.evaluate(tf.function(sample_fn)(mu, a, b))
  
      self.assertAllClose(paths.shape, (num_samples, 3, 2), atol=0)
      means = np.mean(paths, axis=0)
      times = np.reshape(times, [-1, 1])
      expected_means = x0 + (2.0 / 3.0) * mu * np.power(times, 1.5)
      self.assertAllClose(means, expected_means, rtol=1e-2, atol=1e-2)
  
file_path: tf-quant-finance/tf_quant_finance/models/euler_sampling_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 EulerSamplingTest obj's underlying member method code with example usage: obj.test_halton_sample_paths_2d(watch_params) and returns: euler_sampling, unknown, unknown