docstr: Tests univariate GBM integrate parameter.
docstr_tok: ["Tests","univariate","GBM","integrate","parameter","."]
code: def test_univariate_integrate_parameter(self, dtype):
      """Tests univariate GBM integrate parameter."""
      # Generate times series for the volatility.
      times = np.linspace(0.0, 10.0, 6, dtype=dtype)
      a_constant = 0.3
      constant_batched = np.random.uniform(size=(2, 3, 4)).astype(dtype)
      # PiecewiseConstFunc's first value is for the interval [-Inf, times[0]).
      time_varying = np.append([0], np.cos(times, dtype=dtype))
      time_varying_fn = tff.math.piecewise.PiecewiseConstantFunc(
          jump_locations=times, values=time_varying, dtype=dtype
      )
      process = tff.models.GeometricBrownianMotion(
          a_constant, a_constant, dtype=dtype
      )
      start_times = np.array([1.0, 3.5, 7.5, 12], dtype=dtype)
      end_times = np.array([2.0, 6.0, 8.5, 16], dtype=dtype)
  
      # Rounding errors in single precision reduce the precision and require a
      # lower tolerance.
      rtol = atol = _tolerance_by_dtype(dtype)
  
      with self.subTest("Constant"):
          integral = process._integrate_parameter(
              a_constant, True, start_times, end_times
          )
          expected = a_constant * (end_times - start_times)
          self.assertAllClose(integral, expected, atol=atol, rtol=rtol)
  
      with self.subTest("Batched"):
          integral = process._integrate_parameter(
              constant_batched, True, start_times, end_times
          )
          expected = constant_batched * (end_times - start_times)
          self.assertAllClose(integral, expected, atol=atol, rtol=rtol)
  
      with self.subTest("Time dependent"):
          integral = process._integrate_parameter(
              time_varying_fn, False, start_times, end_times
          )
          expected = np.array(
              [
                  # Test interval [1.0, 2.0] takes value from t = 0.0.
                  1.0 * np.cos(0.0, dtype=dtype),
                  # Test interval [3.5, 6.0] is covered by the piecewise constant
                  # intervals {[2.0, 4.0), [4.0, 6.0]}.
                  0.5 * np.cos(2.0, dtype=dtype)
                  + 2.0 * np.cos(4.0, dtype=dtype),
                  # Test interval [7.5, 8.5] is covered by the piecewise constant
                  # intervals {[6.0, 8.0), [8.0, 10.0]}.
                  0.5 * np.cos(6.0, dtype=dtype)
                  + 0.5 * np.cos(8.0, dtype=dtype),
                  # Test interval [12, 16] takes the value from t=10
                  4.0 * np.cos(10.0, dtype=dtype),
              ],
              dtype=dtype,
          )
  
          self.assertAllClose(integral, expected, atol=atol, rtol=rtol)
  
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 4 for calling the GeometricBrownianMotionTest obj's underlying member method code with example usage: obj.test_univariate_integrate_parameter(dtype) without return types