tags:

views:

353

answers:

4

I'm analyzing financial data and would like to find the inflection points of a line. I know I can do this using derivatives, but first I need an equation. Is there are way to generate an equation based off of a series of numbers. I would need to do this programmaticly.

+8  A: 

There are established procedures for turning a set of existing data points into a polynomial; this is called Polynomial Interpolation. This article in Wikipedia: http://en.wikipedia.org/wiki/Polynomial_interpolation explains it mathematically. You can probably Google for algorithms easily enough.

Given enough points, your polynomial tracks the original, unknown function reasonably well, so the polynomial's inflection points should roughly coincide with the peaks and troughs of your data.

On the other hand, we all know there's not really a function behind financial data. So if I were you I'd scan along those points and find every point that has a smaller value to either side of it, and declare that a high; and vice versa for lows. Force-fitting this data into a fictitious function isn't going to make it any more useful.

Update: Tom Smith advises that spline interpolation is to be preferred to polynomial interpolation for this kind of thing, and Wikipedia bears him out. Or rather, it's bullish on his answer.

Carl Smotricz
+1 you beat me to it!
Mahesh Velaga
How do you know polynomial interpolation is appropriate without knowing the nature of the data ?
ldigas
It's financial data. It's a series of ups and downs determined by the digestive tracts of a few thousand high-volume traders. [shrug]
Carl Smotricz
You know for a fact or you're just making an unhealthy assumption ?
ldigas
"Financial data" comes from the question. The rest comes from a plausible assumption. Everybody and their dog try the tea leaf reading game on stock market curves. If they passed High School calculus, they try to apply that.
Carl Smotricz
+1 for silly puns
Joe Philllips
+1 for using the data you have rather than some imaginary curve, if possible. (A function is probably necessary if you're trying to make projections, but inflection points are really just local minima/maxima, not a prediction of the future.)
Martha
Well, I just glanced at Samuelsons's blue book at the shelf, and there is a mountain of curves which disagree. Also, from what do you assume that "financial data" relates to "stock market curves"?
ldigas
I've already confessed that I'm making assumptions. Why are you giving me a hard time, do you want me to commit Seppuku for not taking this question any more seriously than I feel it deserves? I happen to harbor the same respect for economics as a science as I do for astrology.
Carl Smotricz
I didn't mind the part about making an assumption; what I did mind was the "plausible" part ... which is well, not. Btw, economics is a scientific discipline (in fact, some of the greatest mathematicians in the last century were devoted to it), while astrology is well, a pseudoscience, or more a system of beliefs.
ldigas
In any case, I'm done in here ... so ... carry on assuming.
ldigas
A: 

What you are thinking is analytical calculus ... when having discrete data (e.g. points), you have to do it numerically. Now, a line usually doesn't have inflection points, so I guess you're thinking of a curve. You can either interpolate some kind of it through the points, then calculate the first derivative (also numerically, but for a larger number of points), or you can just calculate the first derivation from the points you have (which will be better depends on how many points you actually have).

But really, this is just theory since we don't know the nature of data, or the language or anything.

For more on the subject search: numerical analysis on wiki, and go from there.

ldigas
+9  A: 

Spline interpolation is probably more useful for you than polynomial interpolation: if you fit a polynomial, it must inevitably head off to +/- infinity outside your data range.

You will also want a method which allows a slightly loose fit: financial data is often a bit noisy which can result in very weird curves if you try to fit it exactly.

Tom Smith
+1 spline is a good choice as well :)
Mahesh Velaga
Mine is a good answer. Yours is a better answer. +1!
Carl Smotricz
I'd also like to emphasize the last sentence. Financial data is very unlikely to fit any reasonable curve, so any curve that fits exactly will have all sorts of oddities. Look for a more general and smooth function that fits the data pretty well.
David Thornley
awesome! Thanks Tom!
Arron
A: 

Hi

I think curve fitting might help you in this case. Here is a discussion which might be handy.

cheers

Andriyev