# Fit a fourier expansion to some data

Suppose I have some data, given by $\boldsymbol{x}$ and $\boldsymbol{y}$ pairs, for instance$\{(\boldsymbol{x_1}, \boldsymbol{y_1}), (\boldsymbol{x_2},\boldsymbol{y_2}),...,(\boldsymbol{x_n},\boldsymbol{y_n})\}$ for $n\in\mathbb{N}$.

I assume that the data comes from some function $f(\boldsymbol{x})$ with some noise, I don't know the function, so we don't know whether it is periodic (very likely, it is NOT periodic).

This means $\boldsymbol{y_i} = f(\boldsymbol{x_i}) + \boldsymbol{\epsilon_i}$ where $\boldsymbol{\epsilon_i} \sim \textbf{N}(\textbf{0}, \boldsymbol{\sigma}^2))$.

Now I know that the Fourier Series is defined only for periodic functions. However (here) it is possible to "extend" a non-periodic function defined on an interval, to a periodic function.

The amount of data that I have is finite, so will lie in an interval.

So my question is:

Does it make sense (is it even possible) to try and fit a Fourier Series to the data, by considering the data (which is multi-dimensional, both x and y are vectors) in a multi-dimensional interval , by finding the coefficients that minimize some loss function? (for instance Mean Squared Error) How would someone define this fourier series for a multi-dimensional, non-periodic, noisy function?

(by using only a finite number of fourier terms!)