docstr: Tests paths properties for Wiener process (dX = dW).
docstr_tok: ["Tests","paths","properties","for","Wiener","process","(","dX","=","dW",")","."]
code: def test_sample_paths_wiener(
      self, watch_params, use_time_step, use_xla=False
  ):
      """Tests paths properties for Wiener process (dX = dW)."""
  
      def drift_fn(_, x):
          return tf.zeros_like(x)
  
      def vol_fn(_, x):
          return tf.expand_dims(tf.ones_like(x), -1)
  
      times = np.array([0.1, 0.2, 0.3])
      num_samples = 5000
      if watch_params:
          watch_params = []
      else:
          watch_params = None
      if use_time_step:
          time_step = 0.02
          num_time_steps = None
      else:
          time_step = None
          num_time_steps = 15
  
      @tf.function
      def fn():
          return milstein_sampling.sample(
              dim=1,
              drift_fn=drift_fn,
              volatility_fn=vol_fn,
              times=times,
              num_samples=num_samples,
              seed=[1, 42],
              random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
              time_step=time_step,
              num_time_steps=num_time_steps,
              watch_params=watch_params,
          )
  
      if use_xla:
          paths = self.evaluate(tf.xla.experimental.compile(fn))[0]
      else:
          paths = self.evaluate(fn())
  
      self.assertAllEqual(paths.shape, [num_samples, 3, 1])
      means = np.mean(paths, axis=0).reshape([-1])
      covars = np.cov(paths.reshape([num_samples, -1]), rowvar=False)
      expected_means = np.zeros((3,))
      expected_covars = np.minimum(
          times.reshape([-1, 1]), times.reshape([1, -1])
      )
      self.assertAllClose(means, expected_means, rtol=1e-2, atol=1e-2)
      self.assertAllClose(covars, expected_covars, rtol=1e-2, atol=1e-2)
  
file_path: tf-quant-finance/tf_quant_finance/models/milstein_sampling_test.py
imports: import functools
  from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  import tf_quant_finance
  from tensorflow.python.framework import test_util
  from tf_quant_finance.math import gradient
label_desc: Use image node_id 1 for calling the MilsteinSamplingTest obj's underlying member method code with example usage: obj.test_sample_paths_wiener(watch_params, use_time_step, use_xla) and returns: tf, tf, milstein_sampling