Splines Methods

Cubic spline functions used for interpolation.

class flare.mgp.splines_methods.CubicSpline(a, b, orders, values=None)

Forked from Github repository: https://github.com/EconForge/interpolation.py. High-level API for cubic splines. Class representing a cubic spline interpolator on a regular cartesian grid.

Creates a cubic spline interpolator on a regular cartesian grid.

Parameters:
  • a (numpy array of size d (float)) – Lower bounds of the cartesian grid.
  • b (numpy array of size d (float)) – Upper bounds of the cartesian grid.
  • orders (numpy array of size d (int)) – Number of nodes along each dimension (=(n1,…,nd) )
Other Parameters:
 

values (numpy array (float)) – (optional, (n1 x … x nd) array). Values on the nodes of the function to interpolate.

grid

Cartesian enumeration of all nodes.

interpolate(points, values=None, with_derivatives=False)

Interpolate spline at a list of points.

Parameters:
  • points – (array-like) list of point where the spline is evaluated.
  • values – (optional) container for inplace computation.
Return values:

(array-like) list of point where the spline is evaluated.

set_values(values)

Set values on the nodes for the function to interpolate.

class flare.mgp.splines_methods.PCASplines(l_bounds, u_bounds, orders, svd_rank)

Build splines for PCA decomposition, mainly used for the mapping of the variance

Parameters:
  • l_bounds (numpy array) – lower bound for the interpolation. E.g. 1-d for two-body, 3-d for three-body.
  • u_bounds (numpy array) – upper bound for the interpolation.
  • orders (numpy array) – grid numbers in each dimension. E.g, 1-d for two-body, 3-d for three-body, should be positive integers.
  • svd_rank (int) – rank for decomposition of variance matrix, also equal to the number of mappings constructed for mapping variance. For two-body svd_rank<=min(grid_num, train_size*3), for three-body svd_rank<=min(grid_num_in_cube, train_size*3)
flare.mgp.splines_methods.vec_eval_cubic_spline(a, b, orders, coefs, points, values=None)

Forked from Github repository: https://github.com/EconForge/interpolation.py. Evaluates a cubic spline at many points

Parameters:
  • a (numpy array of size d (float)) – Lower bounds of the cartesian grid.
  • b (numpy array of size d (float)) – Upper bounds of the cartesian grid.
  • orders (numpy array of size d (int)) – Number of nodes along each dimension (=(n1,…,nd) )
  • coefs (array of dimension d, and size (n1+2, .., nd+2)) – Filtered coefficients.
  • point (array of size N x d) – List of points where the splines must be interpolated.
  • values (array of size N) – (optional) If not None, contains the result.
Return value:

Interpolated values. values[i] contains spline evaluated at point points[i,:].