GRF#

class pinnx.fnspace.GRF(T=1, kernel='RBF', length_scale=1, N=1000, interp='cubic')[source]#

Gaussian random field (Gaussian process) in 1D.

The random sampling algorithm is based on Cholesky decomposition of the covariance matrix.

Parameters:
  • T (float) – T > 0. The domain is [0, T].

  • kernel (str) – Name of the kernel function. “RBF” (radial-basis function kernel, squared-exponential kernel, Gaussian kernel), “AE” (absolute exponential kernel), or “ExpSineSquared” (Exp-Sine-Squared kernel, periodic kernel).

  • length_scale (float) – The length scale of the kernel.

  • N (int) – The size of the covariance matrix.

  • interp (str) – The interpolation to interpolate the random function. “linear”, “quadratic”, or “cubic”.

eval_batch(features, xs)[source]#

Evaluate a list of functions at a list of points.

Parameters:
  • features – A NumPy array of shape (n_functions, n_features). A list of the feature vectors of the functions to be evaluated.

  • xs – A NumPy array of shape (n_points, dim). A list of points to be evaluated.

Returns:

A NumPy array of shape (n_functions, n_points). The values of different functions at different points.

eval_one(feature, x)[source]#

Evaluate the function at one point.

Parameters:
  • feature – The feature vector of the function to be evaluated.

  • x – The point to be evaluated.

Returns:

The function value at x.

Return type:

float

random(size)[source]#

Generate feature vectors of random functions.

Parameters:

size (int) – The number of random functions to generate.

Returns:

A NumPy array of shape (size, n_features).