Scalar-valued local function approximation across a real-valued vector space


Build Status Coverage Status


This package provides local function approximators that interpolates a scalar-valued function across a vector space. It does so based on the values of the function at "nearby" points, based on an appropriate locality metric, and not via any global regression or fitting function. Currently it supports multi-linear and simplex interpolations for multi-dimensional grids, and k-nearest-neighbor interpolation. Two important dependencies are GridInterpolations and NearestNeighbors.

Installation and Usage

Start Julia and run the following:

using LocalFunctionApproximation

Create Function Approximators

Create a rectangular grid for interpolation using GridInterpolations and create the function approximator that uses it:

using GridInterpolations # Make the grid interpolations module available
grid = RectangleGrid([0., 0.5, 1.],[0., 0.5, 1.])      # rectangular grid
grid_values = [8., 1., 6., 3., 5., 7., 4., 9., 2.]     # corresponding values at each grid point
gifa = LocalGIFunctionApproximator(grid, grid_values)  # create the function approximator using the grid and values

Create a nearest neighbor tree using NearestNeighbors and create the corresponding approximator:

using NearestNeighbors, StaticArrays
points = [SVector(0.,0.), SVector(0.,1.), SVector(1.,1.), SVector(1.,0.)]   # the 4 corners of the unit square
nntree = KDTree(points)                                                     # create a KDTree using the points
vals = [1., 1., -1., -1]                                                    # values corresponding to points
k = 2                                                                       # the k parameter for knn approximator
knnfa = LocalNNFunctionApproximator(nntree, points, k)

Compute values at arbitrary points

point = rand(2)             # random 2D point
compute_value(gifa, point)  # obtain the value by interpolating the function at that point       
compute_value(knnfa, point) # do the same for the kNN approximator

A typical use case for this package is for Local Approximation Value Iteration, as shown here.

First Commit


Last Touched

over 1 year ago


46 commits

Used By: