SumFunction¶

class probnum.functions.SumFunction(*summands)[source]

Bases: Function

Pointwise sum of Functions.

Given functions $$f_1, \dotsc, f_n \colon \mathbb{R}^n \to \mathbb{R}^m$$, this defines a new function

$\sum_{i = 1}^n f_i \colon \mathbb{R}^n \to \mathbb{R}^m, x \mapsto \sum_{i = 1}^n f_i(x).$
Parameters:

*summands (Function) – The functions $$f_1, \dotsc, f_n$$.

Attributes Summary

 input_ndim Syntactic sugar for len(input_shape). input_shape Shape of the function's input. output_ndim Syntactic sugar for len(output_shape). output_shape Shape of the function's output. summands The functions $$f_1, \dotsc, f_n$$ to be added.

Methods Summary

 Evaluate the function at a given input.

Attributes Documentation

input_ndim

Syntactic sugar for len(input_shape).

input_shape

Shape of the function’s input.

For a scalar-input function, this is an empty tuple.

output_ndim

Syntactic sugar for len(output_shape).

output_shape

Shape of the function’s output.

For scalar-valued function, this is an empty tuple.

summands

The functions $$f_1, \dotsc, f_n$$ to be added.

Methods Documentation

__call__(x)

Evaluate the function at a given input.

The function is vectorized over the batch shape of the input.

Parameters:

x (ArrayLike) – shape= batch_shape + input_shape – (Batch of) input(s) at which to evaluate the function.

Returns:

shape= batch_shape + output_shape – Function evaluated at the given (batch of) input(s).

Return type:

fx

Raises:

ValueError – If the shape of x does not match input_shape along its last dimensions.