Multidimensional data interpolation

I have been struggling to perform multidimensional interpolation using values. What I have at the moment are the following:

A: a vector of length a .

B: a vector of length b.

C: a vector of length c.

V : realizations from an unknown function V, recorded in a 3-D array of size (a,b,c).

I hope to obtain interpolated values for V2 , with a much finer grid than A, B, and C.

I first tried to use Interpolations.jl but was unsuccessful. Any insights would be appreciated. Thanks!

If your grid is uniformly-spaced, you can use scaled bsplines, otherwise you’ll need to use gridded interpolation. If the documentation isn’t enough to go on, can you provide a minimal working example with definitions of your vectors?

1 Like

Hi, in my example here, the grids are irregular and defined in a separate function. They are discretized values from random variables and hence difficult to parameterize. I was wondering if there are any ways to interpolate just using these vector elements?

julia> A
11-element Array{Float64,1}:
  0.1
  0.158
  0.251
  0.398
  0.631
  1.0
  1.585
  2.512
  3.981
  6.31
 10.0

julia> B
5-element Array{Float64,1}:
 -5.729
 -5.716
 -5.704
 -5.691
 -5.678

julia> C
5-element Array{Float64,1}:
 -0.823
 -0.411
  0.0
  0.411
  0.823
julia> itp = interpolate((A, B, C), V, Gridded(Linear()));

julia> itp(1, -5.7, 0)
0.35565970118183643
4 Likes

Thanks so much! That worked very well for the example above.

I’m a little puzzled. From the posted example:

A = [0.1,0.158,0.251,0.398,0.631,1.0,1.585,2.512,3.981,6.31,10.0]
B = [-5.729, -5.716, -5.704, -5.691, -5.678]
C = [-0.823, -0.411,  0.0,  0.411,  0.823]

But…
a. V is not defined in the solution,
b. The call to itp is given as itp[1,-5.7,0], although I would have guessed from the documentation of Interpolations that it should have been itp(1,-5.7,0)??

One obvious use of interpolation is with thermodynamics tables, where some data are often missing. Can Interpolations be used for such data, or are there other packages? Example [sorry for the “big” example – missing data are in the last column]:

a) I just created a dummy V = rand(11, 5, 5).
b) Yeah, you’re right - the bracket syntax still works, but has been deprecated for a while.

Interpolations.jl isn’t ideally suited to fill in missing values - Impute.jl should do the trick.

1 Like