Jump to content

Recommended Posts

Posted

Hey there all,

 

this might be a pretty stupid question, but is there a method that allows one to extract the function from a graph? I know that one graph can represent many different functions, but if I didn't care which one, as long as that function would produce the same graph when plotted. Also, I don't mean functions that look like

 

[math]f(x)=\begin{cases} \mbox{something} & \mbox{if } \mbox{something} \\ \mbox{something else} & \mbox{if } \mbox{something else} \\ \mbox{still something else} & \mbox{if } \mbox{still something else} \\ \mbox{\vdots}&\mbox{\vdots} \end{cases}

[/math]

 

..and have a separate condition for every point. I know that one can't represent some functions in any other way, but let's restrict this to functions that can be represented in some meaningful way.

 

Cheers,

 

Gabe

Posted

The method I always use is to (to find polynomial models):

-First find the degree by subtracting the y terms like given the points:

[math]{(2,4) (3,9) (4,16) (5,25) (6,36)}[/math]

[math]9-4=5, 16-9=7, 25-16=9, 36-25=11[/math]

[math]5-7=-2, 7-9=-2, 9-11=-2[/math]

 

Yes I know this is obvious but it was an quick example.

 

The degree is the number of subtractions needed to find a constant difference. Like in the example above it is a second degree polynomial.

1 subtraction- Linear

2 Subtractions- Quadratic

3 Subtractions- Cubic

 

Once I have decided the degree I plug the x values into the general form of that equation:

 

[math]Ax^{2}+Bx+C[/math]

[math]A2^{2}+2B+C=4=4A+2B+C=4[/math]

[math]9A+3B+C=9[/math]

[math]16A+4B+C=16[/math]

 

 

Once I have these equations I put them into matrices and solve. Sorry I did not show the matrix work but I can't get the text to work. But this is how I fit polynomials to a set of data.

Posted

Sorry, it looked as if it was what was happening here at the top of the posted link

http://mathworld.wolfram.com/LeastSquaresFitting.html

 

Following on from the post before myne, this method looks verry usefull, thanks.

 

So you can start with an unknown series or graph and end up with the name of the function.

 

1, 2, 4, 8, 16

(1, 1), (2, 2), (3, 4), (4, 8), (5, 16)

 

2 - 1 = 1

4 - 2 = 2

8 - 4 = 4

16 - 8 = 8

 

2 - 1 = 1

4 - 2 = 2

8 - 4 = 4

 

2 - 1 = 1

4 - 2 = 2

 

not working, however I have just realised that this could be because my equation is not a liner, quadratic or cubic equation.

 

Lets try

y = 2x^2+4x+3

y = (2*(x*x))+(4*x)+3

 

(1, 9), (2, 19), (3, 33), (4, 51)

 

19 - 9 = 10

33 - 19 = 14

51 - 33 = 18

 

14 - 10 = 4

18 - 14 = 4

 

So is this a way of proving that y = 2x^2+4x+3 is a quadratic equation?

Posted

So is this a way of proving that y = 2x^2+4x+3 is a quadratic equation?

 

It's quadratic because the 2x^2 terms is the highest power of x that has a non-zero coefficient ;)

 

But if you mean is tehre a way to prove the data fits that then, there are measures of confidence you can apply, but I can't remember their names, and my notes on this are sat on my desk atm... (my undergrad notes are a bit unordered atm) it might be "confidence indicators".

Posted

Does finding the degree of

(1, 9), (2, 19), (3, 33), (4, 51)

using the subrating method and it taking exactly in two iterations give me a confident indication that the above numbers can be represented by a quadratic equation?

 

Is there a difference between the turms coeficent and parameter?

Posted

The term coefficient in this case means the number before the x so:

 

ax^2

 

a is the coefficient.

 

IIRC least squares fitting only really works well on datasets of over 20 (it might be a bit higher than that infact, maybe 50)

Posted (edited)

ty, coeficent and parameter sound fairly interchangeble then.

I preume the last post of myne above this one is the case as it worked and I was trying to interpret what DJBruce said and I think I have done so correctly.

 

Sorry, we seem to have wanded slightly away from the original posters question.

Edited by alan2here
Posted (edited)
So you can start with an unknown series or graph and end up with the name of the function.

 

1, 2, 4, 8, 16

(1, 1), (2, 2), (3, 4), (4, 8), (5, 16)

 

2 - 1 = 1

4 - 2 = 2

8 - 4 = 4

16 - 8 = 8

 

2 - 1 = 1

4 - 2 = 2

8 - 4 = 4

 

2 - 1 = 1

4 - 2 = 2

 

not working, however I have just realised that this could be because my equation is not a liner, quadratic or cubic equation.

 

 

Your next subtraction would be [math]2-1=1[/math] but because you do not have another subtraction to preform at the fourth level you cannot be sure that it is quartic or not. If you had more points then you would be able to see if you actually did get a constant difference at the quartic level.

 

 

Does finding the degree of

(1, 9), (2, 19), (3, 33), (4, 51)

using the subrating method and it taking exactly in two iterations give me a confident indication that the above numbers can be represented by a quadratic equation?

 

When I do the work I find a equation of [math]f(x)=2x^{2}+4x+3

if you plug your points back in:

[math] (2)(1)+(4)(1)+3=9[/math]

[math] (2)(2^{2})+(4)(2)+3=19 [/math]

[math] (2)(3^{2})+(4)(3)+3=33 [/math]

[math] (2)(4^{2})+(4)(4)+3=51 [/math]

So for your four points the equation is an exact model. Although any point that you did not include in fitting the equation might not be an exact match. This is why when doing this you want to take points that are far apart.

Edited by DJBruce
Fixing Mis-Qoute
Posted

One name for the topic being discussed in this thread is regression analysis. An even broader term: numerical analysis. Just to give an idea of how broad this topic is, many colleges and universities offer a course called "Introduction to Numerical Analysis".

 

It sounds like several of you are looking for some magical algorithm that takes in one bunch of data and says "This is a parabola with coefficients A, B, and C", takes in another bunch of data and says "this is an exponential growth curve with time constant tau". That truly would be a magical algorithm, and like unicorns, leprechauns, and flying spaghetti monsters, it doesn't exist.

 

Real data do not come nice and pretty like (0,3), (1,9), (2,19), (3,33), (4,51). Something like (0,3.1), (1,8.9), (2,19.1), (3,233), (4,51.1) is much more realistic. A fourth-order polynomial will fit these five points exactly -- and will be exactly wrong. In general, given N+1 data pairs a Nth order polynomial will always yield a perfect fit. So why is this perfect fit almost always wrong? Suppose you have 1001 measurements at hand. I don't know of a single natural process that follows a 1000th order polynomial. The underlying process is more likely to be much simpler. Knowing what kind of equation one should fit to can be a bit of an art. Having an idea ahead of time (e.g., a scientific theory you are trying to verify) helps a lot.

 

Going back to the data I made up: (0,3.1), (1,8.9), (2,19.1), (3,233), (4,51.1). That penultimate pair, (3,233) is completely out-of-line with the rest of the dataset. If you throw that data pair out, you will get four points that fit quite nicely to a parabola. Discarding outliers is a time-honored technique. Sensors sometimes give completely wrong readings. Lab technicians sometimes make mistakes. Suppose you redo the test at this point and get (3,32.9). That fits with the quadratic model.

 

Throwing out valid data is not a good thing to do. Suppose you redo the test at the point in question and get (3,229). You do it again: (3,236). Now what? Measure at 2.9 and 3.1, that's what. Maybe you've discovered something important. If you had simply followed time-honored tradition you would missed something big. Many serendipitous discoveries happen just like that. This is one of the many reasons a magical equation finder cannot exist.

Posted (edited)

A program to test a series against known methods would be usefull.

 

1, 1, 2, 3, 5, 8, 13, 21

 

analysis

 

suficent points? yes, continuing

all the same? no, continuing

period: large or NA

goes: always up

limit: 1 to 21 found

slope: 0 to 8 found

polynomial level: large or NA (intrestingly chaotic), continuing

fibonarchi: 100%

[math]n_{p} = a^{p}[/math]: best A's found 12.5% match at 1, ...

...

 

results

 

type: fibonarchi

 

I'm going back to uni soon, I might write one if there is any interest, could involve other stuff as well.

http://www.scienceforums.net/forum/showthread.php?t=37239

Edited by alan2here
Posted

Throwing out valid data is not a good thing to do. Suppose you redo the test at the point in question and get (3,229). You do it again: (3,236). Now what? Measure at 2.9 and 3.1, that's what. Maybe you've discovered something important. If you had simply followed time-honored tradition you would missed something big. Many serendipitous discoveries happen just like that. This is one of the many reasons a magical equation finder cannot exist.

 

This was actually something we were taught to do in our first UG year, you do a big very unresolved scan, find an interesting area and concentrate on doing more high resolution scans there... It works well, as long as your first scan isn't too unresolved ;)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.