docstr: Tests path properties for 1-dimensional Black Scholes Merton.
  
  We construct the following Ito process.
  
  ````
  dX = r * X * dt + \sigma * X * dW
  ````
  
  Note, that we're not testing in log space.
docstr_tok: ["Tests","path","properties","for","1-dimensional","Black","Scholes","Merton",".","We","construct","the","following","Ito","process",".","``","``","dX","=","r","*","X","*","dt","+","\\sigma","*","X","*","dW","``","``","Note",",","that","we","'re","not","testing","in","log","space","."]
code: def test_sample_bsm(self):
      r"""Tests path properties for 1-dimensional Black Scholes Merton.
  
      We construct the following Ito process.
  
      ````
      dX = r * X * dt + \sigma * X * dW
      ````
  
      Note, that we're not testing in log space.
      """
      r = 0.5
      sigma = 0.5
  
      def drift_fn(t, x):
          del t
          return r * x
  
      def vol_fn(t, x):
          del t
          return sigma * tf.expand_dims(x, -1)
  
      times = np.array([0.0, 0.1, 0.21, 0.32, 0.43, 0.55])
      num_samples = 10000
      x0 = np.array([0.1])
      paths = self.evaluate(
          milstein_sampling.sample(
              dim=1,
              drift_fn=drift_fn,
              volatility_fn=vol_fn,
              times=times,
              num_samples=num_samples,
              initial_state=x0,
              random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
              time_step=0.01,
              seed=[1, 42],
          )
      )
  
      euler_paths = self.evaluate(
          euler_sampling.sample(
              dim=1,
              drift_fn=drift_fn,
              volatility_fn=vol_fn,
              times=times,
              num_samples=num_samples,
              initial_state=x0,
              random_type=tff.math.random.RandomType.STATELESS_ANTITHETIC,
              time_step=0.01,
              seed=[1, 42],
          )
      )
  
      mean = np.average(paths)
      stddev = np.std(paths)
      euler_mean = np.average(euler_paths)
      euler_stddev = np.std(euler_paths)
      self.assertAllClose(
          (mean, stddev),
          (euler_mean, euler_stddev),
          rtol=1e-3,
          atol=1e-3,
      )
  
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 3 for calling the MilsteinSamplingTest obj's underlying member method code with example usage: obj.test_sample_bsm() and returns: unknown, unknown