class_docstr: Heston Model with piecewise constant parameters.
  
  Represents the Ito process:
  
  ```None
    dX(t) = -V(t) / 2 * dt + sqrt(V(t)) * dW_{X}(t),
    dV(t) = mean_reversion(t) * (theta(t) - V(t)) * dt
            + volvol(t) * sqrt(V(t)) * dW_{V}(t)
  ```
  
  where `W_{X}` and `W_{V}` are 1D Brownian motions with a correlation
  `rho(t)`. `mean_reversion`, `theta`, `volvol`, and `rho` are positive
  piecewise constant functions of time. Here `V(t)` represents the process
  variance at time `t` and `X` represents logarithm of the spot price at time
  `t`.
  
  `mean_reversion` corresponds to the mean reversion rate, `theta` is the long
  run price variance, and `volvol` is the volatility of the volatility.
  
  See [1] and [2] for details.
  
  #### Example
  
  ```python
  import tf_quant_finance as tff
  import numpy as np
  volvol = tff.math.piecewise.PiecewiseConstantFunc(
      jump_locations=[0.5], values=[1, 1.1], dtype=np.float64)
  process = tff.models.HestonModel(
      mean_reversion=0.5, theta=0.04, volvol=volvol, rho=0.1, dtype=np.float64)
  times = np.linspace(0.0, 1.0, 1000)
  num_samples = 10000  # number of trajectories
  sample_paths = process.sample_paths(
      times,
      time_step=0.01,
      num_samples=num_samples,
      initial_state=np.array([1.0, 0.04]),
      random_type=random.RandomType.SOBOL)
  ```
  
  #### References:
    [1]: Cristian Homescu. Implied volatility surface: construction
      methodologies and characteristics.
      arXiv: https://arxiv.org/pdf/1107.1834.pdf
    [2]: Leif Andersen. Efficient Simulation of the Heston Stochastic
      Volatility Models. 2006.
      Link:
      http://www.ressources-actuarielles.net/ext/isfa/1226.nsf/d512ad5b22d73cc1c1257052003f1aed/1826b88b152e65a7c12574b000347c74/$FILE/LeifAndersenHeston.pdf
class_docstr_tok: ["Heston","Model","with","piecewise","constant","parameters",".","Represents","the","Ito","process",":","``","`","None","dX","(","t",")","=","-V","(","t",")","\/","2","*","dt","+","sqrt","(","V","(","t",")",")","*","dW_","{","X","}","(","t",")",",","dV","(","t",")","=","mean_reversion","(","t",")","*","(","theta","(","t",")","-","V","(","t",")",")","*","dt","+","volvol","(","t",")","*","sqrt","(","V","(","t",")",")","*","dW_","{","V","}","(","t",")","``","`","where","`","W_","{","X","}","`","and","`","W_","{","V","}","`","are","1D","Brownian","motions","with","a","correlation","`","rho","(","t",")","`",".","`","mean_reversion","`",",","`","theta","`",",","`","volvol","`",",","and","`","rho","`","are","positive","piecewise","constant","functions","of","time",".","Here","`","V","(","t",")","`","represents","the","process","variance","at","time","`","t","`","and","`","X","`","represents","logarithm","of","the","spot","price","at","time","`","t","`",".","`","mean_reversion","`","corresponds","to","the","mean","reversion","rate",",","`","theta","`","is","the","long","run","price","variance",",","and","`","volvol","`","is","the","volatility","of","the","volatility",".","See","[","1","]","and","[","2","]","for","details",".","#","#","#","#","Example","``","`","python","import","tf_quant_finance","as","tff","import","numpy","as","np","volvol","=","tff.math.piecewise.PiecewiseConstantFunc","(","jump_locations=","[","0.5","]",",","values=","[","1",",","1.1","]",",","dtype=np.float64",")","process","=","tff.models.HestonModel","(","mean_reversion=0.5",",","theta=0.04",",","volvol=volvol",",","rho=0.1",",","dtype=np.float64",")","times","=","np.linspace","(","0.0",",","1.0",",","1000",")","num_samples","=","10000","#","number","of","trajectories","sample_paths","=","process.sample_paths","(","times",",","time_step=0.01",",","num_samples=num_samples",",","initial_state=np.array","(","[","1.0",",","0.04","]",")",",","random_type=random.RandomType.SOBOL",")","``","`","#","#","#","#","References",":","[","1","]",":","Cristian","Homescu",".","Implied","volatility","surface",":","construction","methodologies","and","characteristics",".","arXiv",":","https",":","\/\/arxiv.org\/pdf\/1107.1834.pdf","[","2","]",":","Leif","Andersen",".","Efficient","Simulation","of","the","Heston","Stochastic","Volatility","Models",".","2006",".","Link",":","http",":","\/\/www.ressources-actuarielles.net\/ext\/isfa\/1226.nsf\/d512ad5b22d73cc1c1257052003f1aed\/1826b88b152e65a7c12574b000347c74\/","$","FILE\/LeifAndersenHeston.pdf"]
docstr: Computes the expected variance of the process up to `future_time`.
  
  The Heston model affords a closed form expression for its expected variance:
  
  `E[S_T] = (V(0) - theta)(1 - e^{-mean_reversion * T})/ mean_reversion +
  theta * T`
  
  Where `S_T` represents the integral of the instantaneous variance process V
  from 0 to `T` [p138. of 1].
  
  ### References
  [1] Gatheral, Jim. The volatility surface: a practitioner's guide. Vol. 357.
    John Wiley & Sons, 2011.
  
  Args:
    future_times: real `Tensor` representing times in the future (`T` in the
      above notation).
    initial_var: real `Tensor` of shape compatible with `future_time`. The
      value of the variance process at time zero, `V(0)`.
    name: Python `str`. The name to give this op.
      Default value: name of the instance + `_expected_total_variance`
  
  Returns:
    The expected variance at `future_time`.
  
  Raises:
    ValueError: for non-constant parameters.
docstr_tok: ["Computes","the","expected","variance","of","the","process","up","to","`","future_time","`",".","The","Heston","model","affords","a","closed","form","expression","for","its","expected","variance",":","`","E","[","S_T","]","=","(","V","(","0",")","-","theta",")","(","1","-","e^","{","-mean_reversion","*","T","}",")","\/","mean_reversion","+","theta","*","T","`","Where","`","S_T","`","represents","the","integral","of","the","instantaneous","variance","process","V","from","0","to","`","T","`","[","p138",".","of","1","]",".","#","#","#","References","[","1","]","Gatheral",",","Jim",".","The","volatility","surface",":","a","practitioner","'s","guide",".","Vol",".","357",".","John","Wiley","&","Sons",",","2011",".","Args",":","future_times",":","real","`","Tensor","`","representing","times","in","the","future","(","`","T","`","in","the","above","notation",")",".","initial_var",":","real","`","Tensor","`","of","shape","compatible","with","`","future_time","`",".","The","value","of","the","variance","process","at","time","zero",",","`","V","(","0",")","`",".","name",":","Python","`","str","`",".","The","name","to","give","this","op",".","Default","value",":","name","of","the","instance","+","`","_expected_total_variance","`","Returns",":","The","expected","variance","at","`","future_time","`",".","Raises",":","ValueError",":","for","non-constant","parameters","."]
code: def expected_total_variance(
      self,
      future_times: types.RealTensor,
      initial_var: types.RealTensor,
      name: Optional[str] = None,
  ) -> types.RealTensor:
      """Computes the expected variance of the process up to `future_time`.
  
      The Heston model affords a closed form expression for its expected variance:
  
      `E[S_T] = (V(0) - theta)(1 - e^{-mean_reversion * T})/ mean_reversion +
      theta * T`
  
      Where `S_T` represents the integral of the instantaneous variance process V
      from 0 to `T` [p138. of 1].
  
      ### References
      [1] Gatheral, Jim. The volatility surface: a practitioner's guide. Vol. 357.
        John Wiley & Sons, 2011.
  
      Args:
        future_times: real `Tensor` representing times in the future (`T` in the
          above notation).
        initial_var: real `Tensor` of shape compatible with `future_time`. The
          value of the variance process at time zero, `V(0)`.
        name: Python `str`. The name to give this op.
          Default value: name of the instance + `_expected_total_variance`
  
      Returns:
        The expected variance at `future_time`.
  
      Raises:
        ValueError: for non-constant parameters.
      """
      for param_name in ["_mean_reversion", "_theta"]:
          param = getattr(self, param_name)
          if not isinstance(param, tf.Tensor):
              raise ValueError(
                  f"Only constant values supported for {param_name}"
              )
      name = name or (self._name + "_expected_total_variance")
      with tf.name_scope(name):
          future_times = tf.convert_to_tensor(
              future_times, self._dtype, name="future_times"
          )
          initial_var = tf.convert_to_tensor(
              initial_var, self._dtype, name="initial_var"
          )
          reversion_strength = (
              1 - tf.math.exp(-self._mean_reversion * future_times)
          ) / self._mean_reversion
          return (
              initial_var - self._theta
          ) * reversion_strength + self._theta * future_times
  
file_path: tf-quant-finance/tf_quant_finance/models/heston/heston_model.py
imports: from typing import Union, Callable, Optional
  import numpy
  import tensorflow.compat.v2
  from tf_quant_finance import types
  from tf_quant_finance import utils
  from tf_quant_finance.math import piecewise
  from tf_quant_finance.math import random_ops
  from tf_quant_finance.models import generic_ito_process
  from tf_quant_finance.models import utils
label_desc: Use image node_id 4 for calling the HestonModel obj's underlying member method code with example usage: obj.expected_total_variance(future_times, initial_var, name) and returns: unknown