docstr: Tests the mean and vol of the univariate GBM sampled paths.
docstr_tok: ["Tests","the","mean","and","vol","of","the","univariate","GBM","sampled","paths","."]
code: def test_multivariate_sample_mean_and_variance(
      self, supply_draws, dtype
  ):
      """Tests the mean and vol of the univariate GBM sampled paths."""
      means = 0.05
      volatilities = [0.1, 0.2]
      corr_matrix = [[1, 0.1], [0.1, 1]]
      process = tff.models.MultivariateGeometricBrownianMotion(
          dim=2,
          means=means,
          volatilities=volatilities,
          corr_matrix=corr_matrix,
          dtype=dtype,
      )
      times = [0.1, 0.5, 1.0]
      initial_state = [1.0, 2.0]
      num_samples_local = 10000
      normal_draws = None
      if supply_draws:
          num_samples_local = 50000
          normal_draws = tf.random.stateless_normal(
              [num_samples_local // 2, 3, 2], seed=[4, 2], dtype=dtype
          )
          normal_draws = tf.concat(
              [normal_draws, -normal_draws], axis=0
          )
      samples = process.sample_paths(
          times=times,
          initial_state=initial_state,
          random_type=tff.math.random.RandomType.SOBOL,
          num_samples=num_samples_local,
          normal_draws=normal_draws,
      )
      log_s = tf.math.log(samples)
      mean = tf.reduce_mean(log_s, axis=0, keepdims=True)
      var = tf.reduce_mean((log_s - mean) ** 2, axis=0)
      expected_mean = (
          process._means - process._vols**2 / 2
      ) * np.array(np.expand_dims(times, -1)) + np.log(initial_state)
      expected_var = process._vols**2 * np.array(
          np.expand_dims(times, -1)
      )
      with self.subTest("Drift"):
          self.assertAllClose(
              tf.squeeze(mean), expected_mean, atol=1e-3, rtol=1e-3
          )
      with self.subTest("Variance"):
          self.assertAllClose(
              tf.squeeze(var), expected_var, atol=1e-3, rtol=1e-3
          )
      with self.subTest("Correlations"):
          samples = self.evaluate(samples)
          for i in range(len(times)):
              corr = np.corrcoef(samples[:, i, :], rowvar=False)
          self.assertAllClose(corr, corr_matrix, atol=1e-2, rtol=1e-2)
  
imports: 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.models.geometric_brownian_motion import geometric_brownian_motion_test_utils
  from tf_quant_finance.models.geometric_brownian_motion import univariate_geometric_brownian_motion
label_desc: Use image node_id 18 for calling the GeometricBrownianMotionTest obj's underlying member method code with example usage: obj.test_multivariate_sample_mean_and_variance(supply_draws, dtype) without return types