# math¶

zfit.z.math.autodiff_gradient(func: Callable, params: Iterable[zfit.Parameter]) → tensorflow.python.framework.ops.Tensor[source]

Calculate using autodiff the gradients of func() wrt params.

Automatic differentiation (autodiff) is a way of retreiving the derivative of x wrt y. It works by consecutively applying the chain rule. All that is needed is that every operation knows its own derivative. TensorFlow implements this and anything using tf.* operations only can use this technique.

Args:

func (Callable): Function without arguments that depends on params params (ZfitParameter): Parameters that func implicitly depends on and with respect to which the

derivatives will be taken.

Returns:

zfit.z.math.autodiff_hessian(func: Callable, params: Iterable[zfit.Parameter], hessian=None) → tensorflow.python.framework.ops.Tensor[source]

Calculate using autodiff the hessian matrix of func() wrt params.

Automatic differentiation (autodiff) is a way of retrieving the derivative of x wrt y. It works by consecutively applying the chain rule. All that is needed is that every operation knows its own derivative. TensorFlow implements this and anything using tf.* operations only can use this technique.

Args:

func (Callable): Function without arguments that depends on params params (ZfitParameter): Parameters that func implicitly depends on and with respect to which the

derivatives will be taken.

Returns:

tf.Tensor: hessian matrix

zfit.z.math.autodiff_value_gradients(func: Callable, params: Iterable[zfit.Parameter]) → [<class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>][source]

Calculate using autodiff the gradients of func() wrt params; also return func().

Automatic differentiation (autodiff) is a way of retreiving the derivative of x wrt y. It works by consecutively applying the chain rule. All that is needed is that every operation knows its own derivative. TensorFlow implements this and anything using tf.* operations only can use this technique.

Args:

func (Callable): Function without arguments that depends on params params (ZfitParameter): Parameters that func implicitly depends on and with respect to which the

derivatives will be taken.

Returns:

zfit.z.math.automatic_value_gradients_hessian(func: Callable = None, params: Iterable[zfit.Parameter] = None, value_grad_func=None, hessian=None) → [<class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>][source]

Calculate using autodiff the gradients and hessian matrix of func() wrt params; also return func().

Automatic differentiation (autodiff) is a way of retreiving the derivative of x wrt y. It works by consecutively applying the chain rule. All that is needed is that every operation knows its own derivative. TensorFlow implements this and anything using tf.* operations only can use this technique.

Args:

func (Callable): Function without arguments that depends on params params (ZfitParameter): Parameters that func implicitly depends on and with respect to which the

derivatives will be taken.

Returns:

tuple(tf.Tensor, tf.Tensor, tf.Tensor): value, gradient and hessian matrix

zfit.z.math.interpolate(t, c)[source]

Multilinear interpolation on a rectangular grid of arbitrary number of dimensions.

Parameters
• t (tf.Tensor) – Grid (of rank N)

• c (tf.Tensor) – Tensor of coordinates for which the interpolation is performed

Returns

1D tensor of interpolated value

Return type

tf.Tensor

zfit.z.math.numerical_gradient(func: Callable, params: Iterable[zfit.Parameter]) → tensorflow.python.framework.ops.Tensor[source]

Calculate numerically the gradients of func() with respect to params.

Parameters
• func (Callable) – Function without arguments that depends on params

• params (ZfitParameter) – Parameters that func implicitly depends on and with respect to which the derivatives will be taken.

Returns

Return type

tf.Tensor

zfit.z.math.numerical_hessian(func: Callable, params: Iterable[zfit.Parameter], hessian=None) → tensorflow.python.framework.ops.Tensor[source]

Calculate numerically the hessian matrix of func with respect to params.

Parameters
• func (Callable) – Function without arguments that depends on params

• params (ZfitParameter) – Parameters that func implicitly depends on and with respect to which the derivatives will be taken.

Returns

hessian matrix

Return type

tf.Tensor

zfit.z.math.numerical_value_gradients(func: Callable, params: Iterable[zfit.Parameter]) → [<class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>][source]

Calculate numerically the gradients of func() with respect to params, also returns the value of func().

Parameters
• func (Callable) – Function without arguments that depends on params

• params (ZfitParameter) – Parameters that func implicitly depends on and with respect to which the derivatives will be taken.

Returns

Return type

tuple(tf.Tensor, tf.Tensor)

zfit.z.math.numerical_value_gradients_hessian(func: Callable, params: Iterable[zfit.Parameter], hessian: Optional[str] = None) → [<class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>, <class 'tensorflow.python.framework.ops.Tensor'>][source]

Calculate numerically the gradients and hessian matrix of func() wrt params; also return func().

Parameters
• func (Callable) – Function without arguments that depends on params

• params (ZfitParameter) – Parameters that func implicitly depends on and with respect to which the derivatives will be taken.

Returns

Return type

tuple(tf.Tensor, tf.Tensor, tf.Tensor)

zfit.z.math.poly_complex(*args, real_x=False)[source]

Complex polynomial with the last arg being x.

Parameters
• *args (tf.Tensor or equ.) – Coefficients of the polynomial

• real_x (bool) – If True, x is assumed to be real.

Returns

Return type

tf.Tensor