tf_quant_finance.math.integration.integrate

Last updated: 2023-03-16.

tf_quant_finance.math.integration.integrate#

View source

Evaluates definite integral.

tf_quant_finance.math.integration.integrate(
    func, lower, upper, method=tf_quant_finance.math.integration.IntegrationMethod.C
    OMPOSITE_SIMPSONS_RULE, dtype=None, name=None, **kwargs
)

Example#

  f = lambda x: x*x
  a = tf.constant(0.0)
  b = tf.constant(3.0)
  integrate(f, a, b) # 9.0

Args:#

  • func: Represents a function to be integrated. It must be a callable of a single Tensor parameter and return a Tensor of the same shape and dtype as its input. It will be called with a Tesnor of shape lower.shape + [n] (where n is integer number of points) and of the same dtype as lower.

  • lower: Represents the lower limits of integration. func will be integrated between each pair of points defined by lower and upper.

  • upper: Same shape and dtype as lower representing the upper limits of intergation.

  • method: Integration method. Instance of IntegrationMethod enum. Default is IntegrationMethod.COMPOSITE_SIMPSONS_RULE.

  • dtype: Dtype of result. Must be real dtype. Defaults to dtype of lower.

  • name: The name to give to the ops created by this function. Default value: None which maps to ‘integrate’.

  • **kwargs: Additional parameters for specific integration method.

Returns:#

Tensor of the same shape and dtype as lower, containing the value of the definite integral.

Raises: ValueError if method was not recognized.