# Interpolations on scatter data of fun= f(x,y,z)

**URL:** <https://discourse.julialang.org/t/interpolations-on-scatter-data-of-fun-f-x-y-z/125754>\
**Category:** General Usage\
**Tags:** interpolations\
**Created:** [February 10, 2025, 4:44pm UTC](https://discourse.julialang.org/t/interpolations-on-scatter-data-of-fun-f-x-y-z/125754 "2025-02-10T16:44:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Van\_Sy\_Tnut](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/van_sy_tnut/32/217602_2.png) [@Van\_Sy\_Tnut](https://discourse.julialang.org/u/Van_Sy_Tnut)\
**Post date:** [February 10, 2025, 4:44pm UTC](https://discourse.julialang.org/t/interpolations-on-scatter-data-of-fun-f-x-y-z/125754/1 "2025-02-10T16:44:12Z")

</div>

Hello everyone,  
If I have scatter data of control points with x, y, z coordinates and its corresponding output (A). How can I find the interpolation for A = f(x,y,z) ? where x, y, z and A are vectors.  
Thank you so much for you help.

```julia
# ---True function----
func(x,y,z) = x .+ y.^2 .+ z
# ----Data---
x_train = 5*rand(10)
y_train = 5*rand(10)
z_train = 5*rand(10)
A = func.(x_train,y_train,z_train)
# ====Interpolation for A = f(x_train,y_train,z_train) ? ===

```

---

<div class="post-metadata">

**Author:** ![JM\_Beckers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jm_beckers/32/22482_2.png) [@JM\_Beckers](https://discourse.julialang.org/u/JM_Beckers)\
**Post date:** [February 10, 2025, 4:52pm UTC](https://discourse.julialang.org/t/interpolations-on-scatter-data-of-fun-f-x-y-z/125754/2 "2025-02-10T16:52:05Z")

</div>

Some tools can be found in the discussion here

> [@2D Interpolation on an irregular grid](https://discourse.julialang.org/t/2d-interpolation-on-an-irregular-grid/105247):
>
> I want to do 2D interpolation on an irregular grid. In particular, I have a function f:\mathbb R^2 \rightarrow \mathbb R, (x, y) \mapsto z. I have an irregular grid D = (x\_i, y\_i)\_i as well as the corresponding values F = (f\_i)\_i. I would like to interpolate D, F to obtain f. I have tried Dierckx, which according to the documentation supports 2D interpolation on irregular grids, but keeps giving me the following error: “No more knots can be added because the additional knot would (quasi) coi…

some of them will probably work in 3D too. You should also consider if your data are “perfect” or if they contain noise before choosing an interpolation method. With DIVAnd, you can do something like

```julia
using DIVAnd
func(x,y,z) = x .+ y.^2 .+ z
# ----Data---
x_train = 5*rand(10)
y_train = 5*rand(10)
z_train = 5*rand(10)
A = func.(x_train,y_train,z_train)
myfun=DIVAndfun((x_train,y_train,z_train),A;epsilon2=0.001)
i=1
@show A[i],myfun(x_train[i],y_train[i],z_train[i])
@show myfun(2.5,2.5,2.5)

```

---

<div class="post-metadata">

**Author:** ![Van\_Sy\_Tnut](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/van_sy_tnut/32/217602_2.png) [@Van\_Sy\_Tnut](https://discourse.julialang.org/u/Van_Sy_Tnut)\
**Post date:** [February 10, 2025, 6:29pm UTC](https://discourse.julialang.org/t/interpolations-on-scatter-data-of-fun-f-x-y-z/125754/3 "2025-02-10T18:29:22Z")

</div>

Thank you so much for your help.

---

<div class="post-metadata">

**Author:** ![JoshuaLampert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshualampert/32/205964_2.png) [@JoshuaLampert](https://discourse.julialang.org/u/JoshuaLampert)\
**Post date:** [February 10, 2025, 9:00pm UTC](https://discourse.julialang.org/t/interpolations-on-scatter-data-of-fun-f-x-y-z/125754/4 "2025-02-10T21:00:02Z")

</div>

One option not mentioned in the above thread is my package KernelInterpolation.jl. It works on scattered data, in arbitrary dimension, and can also handle noisy data.

---

<div class="post-metadata">

**Author:** ![BdeKoning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bdekoning/32/214557_2.png) [@BdeKoning](https://discourse.julialang.org/u/BdeKoning)\
**Post date:** [February 11, 2025, 4:41pm UTC](https://discourse.julialang.org/t/interpolations-on-scatter-data-of-fun-f-x-y-z/125754/5 "2025-02-11T16:41:59Z")

</div>

Are there any desired properties of the interpolation function like smoothness, extrapolation behavior, degrees of freedom in fitting etc.?
