# Radial Basis interpolation multivariable

**URL:** <https://discourse.julialang.org/t/radial-basis-interpolation-multivariable/82196>\
**Category:** Specific Domains\
**Tags:** interpolations\
**Created:** [June 3, 2022, 2:50pm UTC](https://discourse.julialang.org/t/radial-basis-interpolation-multivariable/82196 "2022-06-03T14:50:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomasjones](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@thomasjones](https://discourse.julialang.org/u/thomasjones)\
**Post date:** [June 3, 2022, 2:50pm UTC](https://discourse.julialang.org/t/radial-basis-interpolation-multivariable/82196/1 "2022-06-03T14:50:11Z")

</div>

Hello all,  
I have columns of data that represent independent variables a,b,c and two dependent variables x,y in a non linear system.  
I want to be able to predict x and y given a,b,c. Matlab has a newrb function that does this well. I have not been able to find how to do it in Julia. I have looked at Surrogates and basis function expansions and I can’t see how to set it up  
Thanks

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 3, 2022, 2:53pm UTC](https://discourse.julialang.org/t/radial-basis-interpolation-multivariable/82196/2 "2022-06-03T14:53:52Z")

</div>

> [@thomasjones](#):
>
> I have looked at Surrogates and basis function expansions and I can’t see how to set it up

What have you tried, and what was the problem? Try to put together a [minimal runnable example](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) to illustrate what you are trying to do.

---

<div class="post-metadata">

**Author:** ![thomasjones](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@thomasjones](https://discourse.julialang.org/u/thomasjones)\
**Post date:** [June 3, 2022, 3:55pm UTC](https://discourse.julialang.org/t/radial-basis-interpolation-multivariable/82196/3 "2022-06-03T15:55:27Z")

</div>

Thanks for the reply. I keep thinking it should be simple.One independent one dependent.  
I have data x vs y and I want to input x and get y. This works fine

using Surrogates

x=[0.0035, 0.0045, 0.0175, 0.0585, 0.068, 0.0935, 0.165, 0.2125, 0.241, 0.3615, 0.474, 0.4985, 0.5815, 0.646, 0.654, 0.723, 0.79, 0.837, 0.8731, 0.883, 0.888, 0.8973, 0.9489, 0.9707, 0.9825]  
y=[0.0205, 0.0275, 0.1315, 0.305, 0.3615, 0.411, 0.52, 0.5455, 0.5675, 0.606, 0.6505, 0.6555, 0.697, 0.729, 0.731, 0.776, 0.82, 0.852, 0.8817, 0.8885, 0.893, 0.9012, 0.9502, 0.9715, 0.9835]  
interp=RadialBasis(x,y,0,1)  
val=interp(.4)  
print(val)

now say I have x,y,z data to predict a dependent variable w. how is that set up? how do I pass the values to the function? Thanks

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 4, 2022, 10:14pm UTC](https://discourse.julialang.org/t/radial-basis-interpolation-multivariable/82196/4 "2022-06-04T22:14:10Z")

</div>

> [@thomasjones](#):
>
> now say I have x,y,z data to predict a dependent variable w. how is that set up? how do I pass the values to the function?

You just need an array of tuples, via `xyz = tuple.(x,y,z)`, e.g.

```julia
julia> x, y, z = rand(1000), rand(1000), rand(1000);

julia> w = @. cos(x^2 - y * sin(z*x));

julia> interp = RadialBasis(tuple.(x,y,z), w, [0,0,0], [1,1,1]);

julia> interp((0.2,0.3,0.4))
0.9999134605897768

julia> cos(0.2^2 - 0.3 * sin(0.4*0.2))
0.9998715929517374

```

---

<div class="post-metadata">

**Author:** ![thomasjones](https://avatars.discourse-cdn.com/v4/letter/t/439d5e/32.png) [@thomasjones](https://discourse.julialang.org/u/thomasjones)\
**Post date:** [June 5, 2022, 9:32pm UTC](https://discourse.julialang.org/t/radial-basis-interpolation-multivariable/82196/5 "2022-06-05T21:32:07Z")

</div>

Nicely done thanks

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 6, 2022, 11:31am UTC](https://discourse.julialang.org/t/radial-basis-interpolation-multivariable/82196/6 "2022-06-06T11:31:19Z")

</div>

This isn’t very clear in the Surrogates.jl documentation; if someone wants to make a PR to make the supported datastructures explicit that would be good.
