code: def test_calculate_mean_and_variance_from_sample_paths(self, dtype):
      atol = 1e-12
      num_samples = 2
      sample_paths = np.array(
          [[[1], [1], [1]], [[2], [2], [2]]], dtype=dtype
      )
      (mean, var, std_err_mean, std_err_var) = self.evaluate(
          gmb_utils.calculate_mean_and_variance_from_sample_paths(
              sample_paths, num_samples, dtype
          )
      )
  
      ones = np.ones((3), dtype=dtype)
      expected_mean = 0.34657359027997264  # (ln(1) + ln(2)) / 2.
      expected_var = 0.12011325347955035  # (ln(2) - expected_mean)**2.
      # Standard error of the mean formula taken from
      # https://en.wikipedia.org/wiki/Standard_error.
      expected_se_mean = (
          0.24506453586713678  # sqrt(expected_var / num_samples).
      )
  
      # Standard error of the sample variance (\sigma_{S^2}) is given by:
      # \sigma_{S^2} = S^2.\sqrt(2 / (n-1)).
      # Taken from 'Standard Errors of Mean, Variance, and Standard Deviation
      # Estimators' Ahn, Fessler 2003.
      # (https://web.eecs.umich.edu/~fessler/papers/files/tr/stderr.pdf)
      expected_se_var = 0.16986579209153746  # expected_var * sqrt(2).
  
      self.assertArrayNear(
          mean, ones * expected_mean, atol, msg="comparing means"
      )
      self.assertArrayNear(
          var, ones * expected_var, atol, msg="comparing variances"
      )
      self.assertArrayNear(
          std_err_mean,
          ones * expected_se_mean,
          atol,
          msg="comparing standard error of means",
      )
      self.assertArrayNear(
          std_err_var,
          ones * expected_se_var,
          atol,
          msg="comparing standard error of variances",
      )
  
file_path: tf-quant-finance/tf_quant_finance/models/geometric_brownian_motion/geometric_brownian_motion_test_utils_test.py
imports: from absl.testing import parameterized
  import numpy
  import tensorflow.compat.v2
  from tensorflow.python.framework import test_util
  from tf_quant_finance.models.geometric_brownian_motion import geometric_brownian_motion_test_utils
label_desc: Use image node_id 4 for calling the GeometricBrownianMotionTestUtilsTest obj's underlying member method code with example usage: obj.test_calculate_mean_and_variance_from_sample_paths(dtype) without return types