How to determine a mathematical function from a graph/set of data

Associate
Joined
17 Jul 2011
Posts
2,079
Hi OcUK, thought I'd attempt to tap your collective minds. I'm doing a study at the moment which is attempting to predict a particular value y (velocity) with respect to x (time).

I have a bunch of data obtained using different values of various parameters which affect the velocity, and ideally I'm trying to obtain a function which incorporates all of these parameters and describes the change in velocity over time.

Does anyone know a good way to go about trying to attach a function to a certain graph/set of data and then modifying that (which I can only assume is trial and error) to take the other parameters into account.

One of the graphs is shown below, which seems to be some kind of inverse square function, but I don't have a huge background in theoretical maths so I'm struggling to get any further!

Any pointers/websites/programs I can use to help me out? Excel doesn't seem to like fitting trendlines to inverse squares although I'm probably just not aware of how to do so!

NfyewLk.png


Thanks :)
 
A few suggestions:

If it might be an inverse relationship, plot 1/thing

If it might be a power relationship, plot log(thing)

The hope in both cases is that the end result looks like a straight line, in which case you can fit a straight line & then convert back by the inverse of the above transformation.

The general search term you want is probably "regression", it usually involves a parameterised curve where you change the parameters to minimise disagreement with the visible data, as in "least squares" regression.

I've no idea how to do this in Excel - point & click around the GUI and hope for the best :)

edit: A few more thoughts (it's late) - be wary of extrapolating beyond your curves, I think the one you've plotted looks like an exponential decay, the heavyweight approach if you've got a lot of different relationships that you'd like to base predictions on is building a response surface through the data, either generalised least squares or Kriging.
 
Last edited:
Thanks for the response, I hadn't though of plotting the inverse etc. It does indeed look like an exponential decay and fits with the physical nature of what's happening.

I should be able to find an equation that fits the base case (shown in original post), but I think trying to find an equation that encompasses all of the parameters might be a bit optimistic... :(

A long couple of weeks fiddling with Excel ahead of me I think!
 
No worries, glad you're still awake to read it.

Time against ln(velocity) may be interesting then. The kriging approach fits an exponential function in an array of variables to the data - it doesn't handle discontinuities especially well but may prove surprisingly effective if it's a set of related physical phenomena. None of the response surface methods would give you a single equation as such, but most produce a fairly sane system of equations.

It might be more fun (or productive) to spend a few days learning to use matlab or python and a day fitting curves than weeks trying to get sanity out of Excel. Enjoy :)
 
Install GNU Octave, it is the open source version of matlab and that has function fitting tools.
One of the issues is you will find multiple different functions that can fit the data and there is no real way of knowing what is the right function. E.g. It is likely and inverse function but you can always fit a poly line of a certain degree to it. Whatever function you choose to fit is only valid within the bounds of th training data.


Mostly this comes down to trial and error to find good fitting functions. There are methods, e.g. Least squares to optimize different function but you always end up trying to choose which regression model is best. If you really do t get what the function is then you can do things like neural networks or radial basis function networks.

One of the main rules is to try to work out the function from theory, typically data is derived following a physical process so model that process.
 
I'll have a look at Matlab/GNU Octave, thanks.

Converting it to a linear relationship and then continuing my work from there seems to be the first step!

EDIT:

JboBCkB.png


This is looking a lot more doable already!
 
Last edited:
Cant you just run it with a line of best fit in excel and ask it to show the line equation? But use a poly/power line etc.

Cheers,

Nick
 
minitab regression quadratic fitted line plot

If you want to list your data I'll run it for you

I should be fine with my current method for now, but thanks a lot for the offer!

Cant you just run it with a line of best fit in excel and ask it to show the line equation? But use a poly/power line etc.

Cheers,

Nick

Yeah I tried that but none of the options Excel gave wanted to fit my curve, I think the first couple of points are slightly anomalous which might have thrown it off, only noticed once I plotted ln(y).
 
Back
Top Bottom