sample_gp_function

safe_learning.sample_gp_function(discretization, gpfun, number=1, return_function=True)

Sample a function from a gp with corresponding kernel within its bounds.

Parameters:
discretization : ndarray

The discretization on which to draw a sample from the GP. Can be obtained, for example, from GridWorld.all_points.

gpfun : instance of safe_learning.GaussianProcess

The GP from which to draw a sample.

number : int

The number of functions to sample.

return_function : bool, optional

Whether to return a function or the sampled data only.

Returns:
function : list of functions or ndarray

function(x, noise=True) A function that takes as inputs new locations x to be evaluated and returns the corresponding noisy function values as a tensor. If noise=False is set the true function values are returned (useful for plotting).