GRF_KL#

class pinnx.fnspace.GRF_KL(T=1, kernel='RBF', length_scale=1, num_eig=10, N=100, interp='cubic')[source]#

Gaussian random field (Gaussian process) in 1D.

The random sampling algorithm is based on truncated Karhunen-Loeve (KL) expansion.

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

  • kernel (str) – The kernel function. “RBF” (radial-basis function) or “AE” (absolute exponential).

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

  • num_eig (int) – The number of eigenfunctions in KL expansion to be kept.

  • N (int) – Each eigenfunction is discretized at N points in [0, T].

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

bases(sensors)[source]#

Evaluate the eigenfunctions at a list of points sensors.

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).