Using Interpolations
x = rand(50,5)*2 .- 1 # Fake input data
y = rand(50) # Fake output data
itp = interpolate((x,),y, BSpline(Linear()))
ERROR: MethodError: no method matching interpolate(::Tuple{Array{Float64,1}}, ::Array{Float64,1}, ::BSpline{Linear})
Closest candidates are:
interpolate(::Tuple{Vararg{Union{AbstractArray{T,1}, Tuple} where T,N}}, ::AbstractArray{Tel,N}, ::IT) where
{Tel, N, IT<:Union{NoInterp, Tuple{Vararg{Union{NoInterp, Gridded},N} where N}, Gridded}}
at .../.julia/packages/Interpolations/XUr6v/src/gridded/gridded.jl:83

Note that this is quite different from BSpline interpolation — fast Chebyshev interpolation requires data at a very specific set of interpolation points (and achieves exponential accuracy for smooth functions), whereas splines work with a more arbitrary set of points.

Thank you for the reply. If it requires specific data points for interpolation, I won’t be able to use it as this comes from biological data that I cannot control.

I could be wrong here (I mainly use gridded interpolation), but I think it is expecting one vector for each dimension of your knots (x here). Is each column of x a different dimension?

Nope. They are all the same dimension. It was a minimal working example but essentially I have 5 columns that describe the copy number (CN) variability of a particular chromosome x_i and I have a corresponding fitness y. The goal was to use interpolation and have a function f that takes in the CN values and outputs a value e.g. f(X) = Y. I can’t seem to find documented examples in any of the standard packages (e.g. Interpolations, ApproxFun) where they have an input matrix X and output vector Y for the interpolation step.

It does have multivariate grids, but it also describes using the package for scattered data (see page 3). The output does produce a function that allows us to give a vector of 5 values and get out an expected y. I have not dug too deeply into how it works, so I cannot answer to that point. In regards to plotting data in 5D, I’d argue that is a rather difficult concept in general

Perhaps this will also be useful in regards to the R package in terms of the functionality I’m hoping to use in Julia: https://cran.r-project.org/web/packages/chebpol/vignettes/chebpol.pdf. In particular the last few pages (beginning at the end of page 7) discusses the two solvers available for scattered data.

My bad, I just looked back at the ChebyshevApprox.jl package and it still requires that the points lie on a tensor-product grid; it doesn’t support a completely unstructured set of points, which seems to be what you want.

(Of course, you could just do a multivariate polynomial least-squares fit with \ or with LsqFit.jl.)

Just to add that to really get the benefits of Chebyshev interpolation, one should use the relevant Chebyshev nodes; otherwise accuracy degrades significantly.

After staring at it longer, I realize what I wanted is something similar to https://en.wikipedia.org/wiki/Polyharmonic_spline. I did not find this in any of the interpolation packages to my knowledge, so I just went ahead and coded up one myself. Thanks for all the advice.