0
$\begingroup$

Pardon my idiocy, this question has probably been answered somewhere else but I can't find it.

If I had a straight line graph and I wanted to work out the equation I would use y = mx + c

However how would I work it out if the graph looked something like this: enter image description here

I don't know what you'd call this but some sort of line that goes up and down rather than straight. So is there a function for working that out

Thanks,

$\endgroup$
  • $\begingroup$ Not in the sense you are talking about. The graph is a time series with seasonal variations. You could perhaps make predictions the sophistication of which will vary. Maybe look up moving averages. $\endgroup$ – Karl Aug 21 '16 at 14:55
0
$\begingroup$

If you have data points like shown in said graph and you connect them with lines, you're basically doing linear interpolation. I take it that you're basically looking for a way to describe this graph as a single function $f(x)$. When plotting such a graph, which is a linear interpolation of points, you have to use a piecewise definition.

Let $y = f(x)$ with

$$f(x) = \begin{cases}2x+1 & \text{if } 0 \leq x < 1 \\ -x+4 & \text{if } 1 \leq x \leq 4 \end{cases} $$

The resulting graph is then

firstgraph

You can see that the subfunctions themselves are still linear functions for the form $y_i = mx+t$.

secondgraph

I also think that you want to take a look at linear interpolation of a data set itself (https://en.wikipedia.org/wiki/Linear_interpolation#Interpolation_of_a_data_set).

$\endgroup$
  • $\begingroup$ Is that the Fourier series? $\endgroup$ – finnthomas99 Aug 21 '16 at 14:53
  • $\begingroup$ No fourier series involved. This is a first-order interpolation of 3 points ($(0,1), (1,3), (4,0)$). If you want a single function to fit $n$ points you might want to look for en.wikipedia.org/wiki/Polynomial_interpolation. $\endgroup$ – Maximilian Gerhardt Aug 21 '16 at 14:55
  • $\begingroup$ @finnthomas99 No, that's interpolation. A fourier series fit (with fewer fitting parameters than points) looks something like this: researchgate.net/figure/… $\endgroup$ – Bobson Dugnutt Aug 21 '16 at 14:55
0
$\begingroup$

There are infinitely many functions that satisfy a list of points $\{x_i,y_i\}$ (your data, for instance), if the function is allowed to have as many parameters as there are points. Determining those parameters is called fitting the function to the data. A standard choice for obtaining such a function is using what is called a Fourier series.

However, if you're able to find a simpler function that also describes the data well, but doesn't have as many parameters, you're probably on to something (e.g., some structure/law underlying your data). In the case of the graph in your link, though, it seems quite chaotic, and then fitting a function with fewer parameters than points becomes next to impossible.

$\endgroup$
  • $\begingroup$ Oh I see since there is no pattern my best bet is to put the coordinates in a list? $\endgroup$ – finnthomas99 Aug 21 '16 at 14:49
  • $\begingroup$ @finnthomas99 It depends on what you are trying to do - what do you need the function for, and what does the data describe? $\endgroup$ – Bobson Dugnutt Aug 21 '16 at 14:50
  • $\begingroup$ I wanted a way to write out the graph but not by writing the coordinates if you understand ie so rather than (1, 1), (2, 2) (3, 3) and so on write y = x $\endgroup$ – finnthomas99 Aug 21 '16 at 14:58
  • $\begingroup$ @finnthomas99 The best thing (for conveying your data) would probably be to plot all your data points (which is essentially the same as writing out the entire list of coordinates, but much in a much more manageable way), and then also plotting some fitted curve along side (for instance the result of finding a fourier series - you can do this numerically in a lot of programs, for instance Matlab). $\endgroup$ – Bobson Dugnutt Aug 21 '16 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.